Conditions
Conditions define the criteria for triggering actions. In general, each condition is essentially a type:value pair. When all of the conditions associated with a rule are satisfied, Price Rules applies the rule’s actions to qualified items in the customer’s cart.
note
Conditions are optional, but an empty conditions
array must be present within the rule for it to be valid. Empty conditions will always evaluate as true.
Condition properties
Price Rules actions support the following properties, depending on the condition type (see Condition property sets). An asterisk (*) indicates the property is required for all condition types.
Property | Type | Description |
---|---|---|
type * | string enumeration | The type of condition. For details, see Condition types. |
value | integer/string | The value that the condition targets, for example, a customer ID. |
operator | string enumeration | A comparison operator that defines a relation with the value. When the operator evaluates to true, the condition is satisfied. |
name | string | A custom name for the condition. |
Condition types
Price Rules conditions fall into two broad categories: those for targeting customers and those for offering quantity pricing.
Customer-targeted condition types
Type | Description | Child properties | Example use case |
---|---|---|---|
CUSTOMER_GROUP | Targets customers based on their membership in groups created on your storefront’s ecommerce platform. | type , value , operator | Promotions for first-time customers. |
CUSTOMER_ID | Targets customers who are logged into the store based on the customer ID found in the ecommerce platform. | type , value | Promotions for members of a brand loyalty program. |
REF_URL | Targets customers based on the URL in the referer header of their HTTP request to your storefront. | type , value | Promotions for customers who visit your store from a partner website. |
SOURCE | Targets customers based on the value of a custom parameter in the link used to visit your storefront. | type , value | Promotions for customers who visit your store from an email campaign. |
Quantity-pricing condition types
Type | Description | Child properties | Example use case |
---|---|---|---|
QTY_BY_VARIANT | Offers discounts based on the quantity of a product variant in the cart. | type , value , operator | A promotion of “Buy 3 packs of 100 reusable cups (Red Color) to get a $10.00 discount on your purchase”. |
QTY_BY_PRODUCT | Offers discounts based on the number of products in the cart. | type , value , operator | A promotion of “Buy 6 packs of 20 disposable spoons and get a discount of 5% on your purchase”. |
QTY_BY_LINE | Offers discounts based on the total number of items, products or variants, in the cart. | type , value , operator | A promotion of “Buy 10 items and get a discount of $3.00”. |
ORDER_CONDITION | Offers discounts to customers based on a specific shipping address defined within zones. For more information, refer to Create an order condition. | type , value , name | A promotion of “10% reduction in shipping cost for downtown addresses”. |
LINE_ITEM_PROPERTY | Offers discounts to customers based on the properties of the items in the cart. | type , value , name | A promotion of “Buy a ‘Red’ Jacket and get $1.00 off on your purchase”. |
SPEND_X_GET_Y | Offers discounts on Y items if the cart total is equal to or above X price. For more information and an example, refer to the Quantity Pricing page. | type , operator , value | A promotion of “Spend $100, get a free bag”. |
Cart-level condition types
Type | Description | Child properties | Example use case |
---|---|---|---|
CART_LEVEL_DISCOUNT_CONDITION | Offers discounts based on the subtotal of the customer's cart | type , value , operator | A promotion of "Spend $150 or more to get 10% of your entire purchase. |