Docs
Dashboard

Cart predicate language

Last updated View as Markdown

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

FieldAvailable values
currency_codeCurrency code
subtotal, totalcent_amount, currency_code
customerid, email, group, groups
store, price_channelid
shipping_address, billing_addressAddress fields, or null
line_itemsCollection 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

EUR 100 minimum
Code in text

Use a currency condition whenever an amount rule can apply in several markets.

Shipping country

Delivery to Denmark
Code in text

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.

Cart contains an accessory
Code in text

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:

Discount accessory lines
Code in text

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.