Application scope
Dynamic formulas can be used as follows.Dynamic discount formulas
The dynamic discount formula builder applies to:- Order discount
- Product discount
- Reward
- Coupon campaigns
- In-cart promotions
- Referral codes
Dynamic points formulas
The dynamic points formula builder applies to:- Fixed earning rules
- Proportional earning rules
To create formulas in the dashboard, see Create dynamic formulas.
Operand reference
Operands represent the values used inside formulas. Example (paste the expression to the Expression output tab and switch to the Formula builder tab to see the result).Data type
You can use the following data type operands. In some contexts, only number is allowed.Metadata operands
You can use the following metadata operands.Depending on the context, the formula builder may accept either metadata with a number type only, or any type (string, boolean, array, and so on).
Order item operands
You can use the following operands in dynamic discount formulas only (product discounts).Example: Order item operand
Example: Order item operand
If the item price is 10.00, the discount is 1.10.
Cheapest order item operands
You can use the following cheapest order item operands.How the cheapest order item is determined
How the cheapest order item is determined
The cheapest order item is determined as follows when there are several items with the same price.
- First, the formula tries to find the order item with the cheapest price. If there is one item, the formula returns this item. Otherwise, it proceeds to step 2.
- If there are n items that have the same cheapest price, from this n, the formula finds the items with the lowest subtotal. If there is only one item, the formula returns this item. Otherwise, if there are many items, it proceeds to step 3.
- Finally, it returns the first item from the list of the cheapest items with the lowest subtotal.
Most expensive order item operands
You can use the following most expensive order item operands.How the most expensive order item is determined
How the most expensive order item is determined
The most expensive order item is determined as follows when there are several items with the same price.
- First, the formula tries to find the order item with the most expensive price. If there is one item, the formula returns this item. Otherwise, it proceeds to step 2.
- If there are n items that have the same most expensive price, from this n, the formula finds the items with the lowest subtotal. If there is only one item, the formula returns this item. Otherwise, if there are many items, it proceeds to step 3.
- Finally, it returns the first item from the list of the most expensive items with the lowest subtotal.
Order-level operands
You can use the following order-level operands.Voucher operands
You can use the following voucher operands. These operands are unavailable for earning rules.Promotion tier operands
You can use the following promotion tier operands.Customer operands
You can use the following customer operand. It can be combined only with date operands and operators.Date operands
You can use the following date operands.Expression functions
You can use the following formula operators to create complex expressions.Operator reference
You can use the following operators depending on the data type.Number operators
You can use the following operators with the number type.String operators
You can use the following operators with the string type.Date operators
You can use the following operators with the date type.Complex expression operators
Complex expressions combine multiple logical conditions.AND operator
All conditions must evaluate to true.Example: AND operator
Example: AND operator
Give a customer 20% off when:
- they have more than 10 store visits
- AND the purchase occurs on Friday
OR operator
At least one condition must evaluate to true.Example: OR operator
Example: OR operator
Example use case:Give a customer 20% off when:
- they have more than 10 store visits
- OR the purchase occurs on Friday
Nested formulas
Nested formulas allow expressions inside logical conditions. If a condition is true, the logical expression will follow the nested path defined inside the condition. If the condition is false, the logical expression will follow the other path.- more than 4 items AND order > 200 → 25% discount
- more than 4 items only → 15% discount
- otherwise → 10% discount
Switch function
Switch expressions allow different values depending on a factor. Example: discount based on store location.- Boston customers get 10% discount
- New York customers get 15% discount
- Customers from other locations get 5% discount

