Discount code rules
Playwright Checkout Rules decides which codes work, for whom, and whether they stack with your offers. On Shopify Functions, codes must exist in Shopify, and Playwright creates the exact codes your rules check for.
Code templates and conditions
- Apply Discount by Code
- Wildcard Discount Code
- Allow Discount Codes by Pattern
- Disallow All Discount Codes
- Disallow Discount Codes
Any discount rule can also check codes with the Cart Has Discount Code, Cart Has No Discount Code and Exclude Discount Codes cart conditions. See Cart conditions.
Codes must exist in Shopify
Shopify only passes a code to Playwright when it exists as a discount in Shopify. Any other code is turned away by Shopify (“Enter a valid discount code”) before your rules run. Shopify Scripts worked the same way, and merchants created each code by hand.
Codes Playwright creates for you
When you publish line item rules, Playwright collects every exact code they check for and puts them on one code discount in Shopify, “Playwright: discount codes”. That means the codes in:
- Apply Discount by Code rows;
- Wildcard Discount Code patterns without a *;
- Cart Has Discount Code conditions set to Does and Match one of.
When a customer enters one of those codes, the code discount runs your line item rules with that code, and the automatic discount steps aside, so the cart is never discounted twice.
- Codes are compared without regard to capital letters, and each is created once.
- A code that already belongs to another discount in Shopify is left as it is, and keeps working with your rules. The publish result lists these as “Already discount codes in Shopify, so left as they are”.
- When you remove a code from your rules and publish, Playwright deletes it from the code discount. When no rule checks for codes, the code discount is removed.
- Codes you add to the code discount by hand in Shopify are removed the next time you publish. Add them to a rule instead.
- Shopify adds and deletes codes in the background, so a new code can take a little while to work.
Wildcards and patterns need exact codes
Playwright can’t create every code a wildcard could match, so these settings can’t create codes:
- Wildcard Discount Code patterns with a *, like
VIP-CLUB-****; - Allow Discount Codes by Pattern patterns, like
PD##; - Cart Has Discount Code set to “Contain one of”, “Start with one of” or “End with one of”.
For each one, either list the exact codes in the rule (Playwright creates them), or create each code as a discount in Shopify. A code you create in Shopify gives its own discount too, so set its value with that in mind. The rule still publishes, with a warning that names the pattern.
Rejecting codes
Disallow All Discount Codes rejects every code; Disallow Discount Codes rejects codes when its conditions match. The customer sees your message, or a default one if you leave it empty.
- Codes are only rejected when Shopify allows it: Shopify doesn’t let apps reject every code.
- Codes your own rules check for (the codes on “Playwright: discount codes”) are never rejected. While one of them is entered, the automatic discount, which does the rejecting, steps aside.
- Rules see only the first code a customer enters.
Stop discount stacking
To stop a code being used on top of a Playwright offer, add the Exclude Discount Codes cart condition to the offer’s rule:
- Apply discount code only: when a code is entered, the offer doesn’t apply and the code does.
- Reject discount code and apply script: the code is rejected with your message and the offer applies.
- List codes that are exceptions: Reject all codes, except the following keeps the listed codes alongside the offer; Accept all codes, except the following rejects only the listed ones.
How codes combine
- Playwright’s line item discounts (automatic and code) are product discounts. They combine with order discounts and shipping discounts, but not with other product discounts. When another product discount applies to the same items, Shopify’s combination rules decide which one the customer gets.
- Playwright’s shipping discount combines with product and order discounts, but an order gets only one shipping discount.
- Shopify lets customers enter up to 5 product or order codes and one shipping code. Playwright’s rules check the first code entered.
Codes in shipping rules
Shipping discounts can check codes with Cart Has Discount Code, but Playwright only creates codes for line item rules. Create the codes in Shopify, or check the same exact codes in a line item rule too, which creates them. Shipping option rules (hide, rename, reorder) and payment rules can’t see codes.