# Predicate language A predicate is a boolean condition used by a commerce rule. It answers whether a cart, line item, or price record matches that rule. It does not query resources or replace the rule's other configuration. ## Select the right context | Rule | Predicate reads | | --- | --- | | Cart discount, shipping method or rate, payment gateway | [Cart context](/concepts/cart-predicate-language) | | Cart discount line-item target | [One line item](/concepts/cart-predicate-language#line-item-target-predicates) | | Product discount | [Product-price context](/concepts/product-predicate-language) | A search clause such as `tag:lighting` is not a predicate. A full-cart expression using `line_items.any(...)` is not a line-item target expression. The target already represents one line. ## Syntax Use `==`, `!=`, `>`, `>=`, `<`, and `<=` for comparisons. Use `&&`, `||`, and `!` for boolean logic, with parentheses to make grouping explicit. Supported contexts use snake_case fields, string literals, numbers, booleans, and `null`. Collections support the methods documented by their context, including `Contains`, `any`, and `count`. Cart conditions ```text currency_code == "EUR" && subtotal.cent_amount >= 10000 shipping_address != null && shipping_address.country_code == "DK" line_items.any(item => item.quantity >= 2) ``` Compare money in minor units and pair thresholds with currency. Guard nullable values before reading nested fields. Copy resource IDs from Thor and use the expected casing for codes and strings. Write `true` explicitly when a rule intentionally matches every eligible context. ## Test intent, not only syntax Start with one condition and verify it through the supported Admin validation or save operation. Then test a matching case, a non-matching case, and the boundary value. For cart rules, include anonymous customers and missing addresses. For product-price rules, include prices with and without optional dimensions. A matching predicate only establishes eligibility. Scheduling, discount targets, priority, and combination settings can still change the result. Use [Create a discount campaign](/guides/operations/discount-campaign) for a complete workflow.