Skip to content
Docs menu

Buy One Get One

Discount items when customers buy others: buy 2 shirts, get a hat free, or buy one, get one half price. A Playwright Checkout Rules template for cart, pricing and discount codes.

What it does

Playwright counts the items that match the “buy” selection. Every Buy number of them makes one set, up to Maximum sets, and each set discounts Get number of the items that match the “get” selection, cheapest first. The cart must also hold at least Buy number items in total.

If “buy” and “get” select the same items, an item can count both ways. For “buy one, get one free” on the same product, set Buy number 2 and Get number 1: the customer adds 2 and one is free. Buy 1 Get 1 on the same items makes every unit free. See Buy X get Y.

For example:

  • Buy one shirt, get one free
  • Buy 2 shirts, get a hat free

Settings

Find it under Line Item Rules in Playwright, in Buy One Get One. Give the rule a name, fill in these settings and select Save Rule.

All or any criteria
Whether all of the conditions you set must match for the rule to apply, or any one of them. Conditions left at “All” aren’t counted. See All or any.
  • Discount if ALL of the following criteria are met
  • Discount if ANY of the following criteria are met
Eligible Customers
Which customers the rule applies to: “All”, one customer condition, or a Multi-Select that combines up to three. See customer conditions.
Eligible Carts in Checkout
Which carts the rule applies to: “All”, one cart or shipping address condition, or a Multi-Select that combines up to three. See cart conditions and destination conditions.
Eligible Line Items in Cart (items to buy)
The items customers buy to qualify: “All”, one product condition, or a Multi-Select. See product conditions.
Eligible Line Items in Cart (items to get)
The items that get the discount: “All”, one product condition, or a Multi-Select. The cheapest are discounted first.
Discount to apply
The discount to give, with the message customers see next to it at checkout. Every discount rule needs one: with “None” the rule does nothing.
  • Percentage Discount: Takes a percentage off the price of each selected item. 100 makes it free.
  • Fixed Total Discount: Takes up to a total amount, in dollars, off the selected items. Discount items to $0 until maximum reached discounts one item after another until the amount is used up; Split discount between items spreads it over the items in proportion to their prices.
  • Fixed Per Item Discount: Takes a fixed amount, in dollars, off each selected unit. A price never goes below $0.
  • Tax Discount: Removes the tax included in the price, for customers who shouldn’t pay it when your prices include tax. Enter the tax rate your prices include, as a percentage.
Buy number
How many “buy” items make one set.
Get number
How many “get” items each set discounts.
Maximum sets
The most sets discounted in one order. Enter 0 for no limit. Buy 2 Get 1 is one set.

Example: Buy 2 shirts, get a hat free

  1. Items to buy: Product Type, Is one of, Shirt.
  2. Items to get: Product Type, Is one of, Hat.
  3. Discount to apply: Percentage Discount, 100, “Free hat”.
  4. Buy number 2, Get number 1, Maximum sets 0.

At checkout: 4 shirts and 2 hats make 2 sets, so both hats are free. 3 shirts and 2 hats make 1 set: the cheaper hat is free.

On Shopify Functions

Playwright publishes this template as part of the Shopify discount “Playwright: discount rules”, and as “Playwright: discount codes” when its rules check for codes.

It runs as it did with Shopify Scripts.

These conditions aren’t available in discount rules, so a rule that uses one isn’t published:

  • Customer Accepts Marketing: Shopify Functions can’t see whether a customer accepts marketing. Tag those customers and use a customer tag condition instead.
  • Has Properties: Line item properties aren’t available to Shopify Functions.
  • Cart Total Weight: Cart weight isn’t available to Shopify Functions.
  • PO Box Qualifier: Street addresses aren’t available to discount rules. Use this condition in shipping or payment rules.
  • Full Address Qualifier: Street addresses aren’t available to discount rules. Use this condition in shipping or payment rules.
  • Compare to billing address: Shopify Functions can’t compare billing and shipping addresses here.
  • Discounted Cart Subtotal (applied by discount code): Shopify Functions only see the discount code itself, not its type or value.

Tag conditions match whole tags only. See Conditions and Publishing.