Cart predicate language

Cart predicates are boolean expressions evaluated against the current cart.

Thor uses them to decide whether a checkout rule is eligible. If the predicate returns true, the rule can apply. If it returns false, the rule is ignored for that cart.

Use this language for:

  • CartDiscount.predicate
  • ShippingMethod.predicate
  • AbsoluteShippingMethodRate.predicate
  • RelativeShippingMethodRate.predicate

Empty predicates are treated as true.

Available context

Thor evaluates cart predicates against resolved checkout data.

Common top-level fields include:

  • customer
  • shipping_address
  • billing_address
  • total
  • subtotal
  • currency_code
  • store
  • price_channel
  • line_items

That means predicates describe business eligibility, not frontend state.

Common patterns

Most production predicates follow a few repeatable patterns:

  • customer targeting
  • country or address targeting
  • minimum subtotal checks
  • line-item filtering

Keep the predicate focused on eligibility. Put cart-wide eligibility on the main discount or shipping rule, and line-item-specific checks on line-item target predicates.