Cart predicate language
Cart predicate language
Cart predicates read the current cart context. Use them for cart discounts, shipping methods and rates, and payment-gateway eligibility. A matching expression makes a rule eligible; the rest of its configuration still determines the result.
Cart fields
| Field | Available values |
|---|---|
currency_code | Currency code |
subtotal, total | cent_amount, currency_code |
customer | id, email, group, groups |
store, price_channel | id |
shipping_address, billing_address | Address fields, or null |
line_items | Collection of line-item contexts |
For anonymous carts, customer identity strings are empty and customer.groups is empty.
Use customer.groups.Contains(...) when expressing membership in a group.
Missing store or price-channel IDs are empty strings in this context.
Address fields include first_name, last_name, email, phone, company, address1, address2, city, zip_code, province, state, and country_code.
Guard the address against null before accessing a field.
These predicate names are not the GraphQL address input’s field names.
Minimum basket amount
Use a currency condition whenever an amount rule can apply in several markets.
Shipping country
A cart without a shipping address does not qualify for this condition. Re-evaluate the returned shipping options after the address changes.
Line-item context
Each line exposes line_item_id, currency_code, quantity, amount, variant, and product.
amount.unit_price and amount.original_unit_price expose cent_amount and currency_code.
variant exposes id, name, sku, and weight_in_kg.
product exposes id, name, tags, categories, and collections; category and collection entries expose id.
Weights use kilograms; money uses minor currency units.
Line-item target predicates
A line-item discount target reads one line directly.
Use the same line fields without the line_items collection prefix:
Use true when every line should be eligible for the target.
A qualifying cart can have no matching target lines, so test both the cart rule and target.
Test missing addresses, anonymous and signed-in customers, multiple groups, and quantities on either side of the threshold. See Create a discount campaign and Predicate language.