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.

TypeOperatorsFieldsAvailable In
customerTaghasAny, hasNonetagsAll 4 functions
customerIsAuthenticatedEquality (none)boolValueAll 4 functions
customerOrderCountNumeric (5 in the editor)value, valueToAll 4 functions
customerTotalSpentNumeric (5 in the editor)value, valueToAll 4 functions
cartSubtotalNumeric (5 in the editor)value, valueToAll 4 functions
cartTotalQuantityNumeric (5 in the editor)value, valueToAll 4 functions
cartLineCountNumeric (4 in the editor)value, valueToAll 4 functions
cartAttributeexists, notExists, equals, containskey, valuesAll 4 functions
marketisAny, isNonecountryCodesAll 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.

TypeOperatorsFieldsAvailable In
productTaghasAny, hasNonetagsAll 4 functions
collectioninAny, inNonecollectionIdsAll 4 functions
productisAny, isNoneproductIdsAll 4 functions
productVariantisAny, isNonevariantIdsAll 4 functions
linePropertyexists, notExists, equals, containskey, valuesAll 4 functions
lineQuantityNumeric (4 in the editor)value, valueToAll 4 functions
linePriceNumeric (4 in the editor)value, valueToAll 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:

OperatorDescriptionRequired FieldsOffered in the discount and validation editors
greaterThanValue must be strictly greater than the thresholdvalueAll 7 numeric types
greaterThanOrEqualValue must be greater than or equal to the thresholdvalueAll 7 numeric types
lessThanValue must be strictly less than the thresholdvalueAll 7 numeric types
lessThanOrEqualValue must be less than or equal to the thresholdvalueNone
equalsValue must exactly equal the thresholdvalueAll 7 numeric types
betweenValue must fall within a range (inclusive)value, valueTocustomerOrderCount, 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 TypeConditionalVolume & TieredBuy X Get YBundle
customerTagYesYesYesYes
customerIsAuthenticatedYesYesYesYes
customerOrderCountYesYesYesYes
customerTotalSpentYesYesYesYes
cartSubtotalYesYesYesYes
cartTotalQuantityYesYesYesYes
cartLineCountYesYesYesYes
cartAttributeYesYesYesYes
marketYesYesYesYes
productTagYesYesYesYes
collectionYesYesYesYes
productYesYesYesYes
productVariantYesYesYesYes
linePropertyYesYesYesYes
lineQuantityYesYesYesYes
linePriceYesYesYesYes

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:

FunctionEffect of product-level conditions
Conditional, Volume & TieredUnder 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.
BXGYOnly matching lines count as buy items or get items. buyItemFilter and getItemFilter then match among those lines.
BundleOnly 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.