Wildcard Discount Code
Give one discount for every code that fits a pattern, like VIP-CLUB-****, where each * stands for any one character. A Playwright Checkout Rules template for cart, pricing and discount codes.
What it does
A code matches when it has the same parts, separated by hyphens, of the same length as the pattern, with the same characters wherever the pattern doesn’t have a *. Capital letters don’t matter.
Shopify only accepts codes that exist, and Playwright can’t create every code a wildcard could match. For a pattern with a *, list the exact codes in the rule as extra patterns without a * (Playwright creates those for you), or create each code as a discount in Shopify.
For example:
- $5 off when using a discount code matching pattern VIP-CLUB-ID-**
Settings
Find it under Line Item Rules in Playwright, in Discount Codes. 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
- Which items in the cart get the discount: “All” items, one product condition, or a Multi-Select. See product conditions.
- 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.
- Patterns to match
- One or more patterns. Use * for any one character:
**-****matchesAB-4321. A pattern without a * is an exact code, and Playwright creates it in Shopify when you publish.
Example: $5 off for club members
- Patterns to match:
VIP-CLUB-0001,VIP-CLUB-0002,VIP-CLUB-0003. - Discount to apply: Fixed Total Discount, 5, “Club member discount”.
At checkout: Each of the three codes takes $5 off, and Playwright creates all three when you publish. With the pattern VIP-CLUB-**** instead, Shopify would only accept the codes you had created in Shopify yourself.
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.
- Shopify only passes codes that exist in Shopify. Patterns without a * are created for you as “Playwright: discount codes” when you publish; codes that only match a pattern with a * must be created in Shopify. See Wildcards and patterns.
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.