Conditions Overview
Alfo - Discount Functions supports 16 condition types organized into two categories: cart-level conditions that evaluate once against the entire cart, and product-level conditions that evaluate individually per cart line. Understanding the distinction between these categories is fundamental to building effective discount rules.
Cart-Level Conditions (9 Types)
Cart-level conditions are evaluated once against the overall cart state. If a cart-level condition fails (in AND logic), the entire rule group fails. No per-line evaluation occurs.
| Type | Operators | Fields | Available In |
|---|---|---|---|
customerTag | hasAny, hasNone | tags | All 4 functions |
customerIsAuthenticated | Equality (none) | boolValue | All 4 functions |
customerOrderCount | Numeric (5 in the editor) | value, valueTo | All 4 functions |
customerTotalSpent | Numeric (5 in the editor) | value, valueTo | All 4 functions |
cartSubtotal | Numeric (5 in the editor) | value, valueTo | All 4 functions |
cartTotalQuantity | Numeric (5 in the editor) | value, valueTo | All 4 functions |
cartLineCount | Numeric (4 in the editor) | value, valueTo | All 4 functions |
cartAttribute | exists, notExists, equals, contains | key, values | All 4 functions |
market | isAny, isNone | countryCodes | All 4 functions |
For detailed documentation of each cart-level condition, see the Cart-Level Conditions reference.
Product-Level Conditions (7 Types)
Product-level conditions are evaluated per cart line. They determine which individual lines are eligible for the discount rather than whether the rule fires at all.
| Type | Operators | Fields | Available In |
|---|---|---|---|
productTag | hasAny, hasNone | tags | All 4 functions |
collection | inAny, inNone | collectionIds | All 4 functions |
product | isAny, isNone | productIds | All 4 functions |
productVariant | isAny, isNone | variantIds | All 4 functions |
lineProperty | exists, notExists, equals, contains | key, values | All 4 functions |
lineQuantity | Numeric (4 in the editor) | value, valueTo | All 4 functions |
linePrice | Numeric (4 in the editor) | value, valueTo | All 4 functions |
For detailed documentation of each product-level condition, see the Product-Level Conditions reference.
Numeric Operators
Checkout evaluates six numeric operators for every condition type marked “Numeric” in the tables above. The discount editors and the validation editor offer only some of them for each type:
| Operator | Description | Required Fields | Offered in the discount and validation editors |
|---|---|---|---|
greaterThan | Value must be strictly greater than the threshold | value | All 7 numeric types |
greaterThanOrEqual | Value must be greater than or equal to the threshold | value | All 7 numeric types |
lessThan | Value must be strictly less than the threshold | value | All 7 numeric types |
lessThanOrEqual | Value must be less than or equal to the threshold | value | None |
equals | Value must exactly equal the threshold | value | All 7 numeric types |
between | Value must fall within a range (inclusive) | value, valueTo | customerOrderCount, customerTotalSpent, cartSubtotal, cartTotalQuantity |
The editors do not offer lessThanOrEqual, and they do not offer between for cartLineCount, lineQuantity, or linePrice. Checkout still evaluates these operators, so a configuration written another way, such as through the Admin API, still works. The editor shows such a condition as it is. The payment, delivery, and upsell editors offer between for every numeric type they support.
When using the between operator, value represents the lower bound and valueTo represents the upper bound (both inclusive).
{
"type": "cartSubtotal",
"operator": "between",
"value": 50,
"valueTo": 200
}
AND/OR Logic
Conditions within a rule group are combined using the conditionLogic field, which accepts either "and" or "or". The behavior of these operators differs in nuanced ways, particularly when mixing cart-level and product-level conditions together.
For a full explanation of how AND and OR logic interact with the two condition categories, including edge cases and worked examples, see the Rule Groups & Logic reference.
Condition Availability Matrix
All four discount functions support all 16 condition types. The matrix below shows the support for each condition type in each of the four discount functions.
| Condition Type | Conditional | Volume & Tiered | Buy X Get Y | Bundle |
|---|---|---|---|---|
customerTag | Yes | Yes | Yes | Yes |
customerIsAuthenticated | Yes | Yes | Yes | Yes |
customerOrderCount | Yes | Yes | Yes | Yes |
customerTotalSpent | Yes | Yes | Yes | Yes |
cartSubtotal | Yes | Yes | Yes | Yes |
cartTotalQuantity | Yes | Yes | Yes | Yes |
cartLineCount | Yes | Yes | Yes | Yes |
cartAttribute | Yes | Yes | Yes | Yes |
market | Yes | Yes | Yes | Yes |
productTag | Yes | Yes | Yes | Yes |
collection | Yes | Yes | Yes | Yes |
product | Yes | Yes | Yes | Yes |
productVariant | Yes | Yes | Yes | Yes |
lineProperty | Yes | Yes | Yes | Yes |
lineQuantity | Yes | Yes | Yes | Yes |
linePrice | Yes | Yes | Yes | Yes |
The 9 cart-level conditions decide whether a rule group applies. The 7 product-level conditions act on cart lines, and their effect depends on the function:
| Function | Effect of product-level conditions |
|---|---|
| Conditional, Volume & Tiered | Under a "filtered" product target, only matching lines get the discount. Under "all" or "specific", they are a gate: at least one line that is not a gift card must match. An order discount leaves out the lines that do not match. |
| BXGY | Only matching lines count as buy items or get items. buyItemFilter and getItemFilter then match among those lines. |
| Bundle | Only matching lines can fill bundle slots. bundleItems[].filter then matches among those lines. |
With OR logic, a passing cart-level condition skips the product-level conditions. Shipping discounts check only the 9 cart-level conditions. The Bundle shipping discount also needs a complete bundle, and the BXGY shipping discount needs enough items for at least one get item.
Rejection rules support all 16 condition types in all 4 functions. See Rejection Rules.