Skip to main content
The dynamic formula builder defines how discount or loyalty point values are calculated. Instead of using a static value for discounts or loyalty points, you can create formulas using mathematical and logical operators combined with metadata values. The final value is calculated dynamically during redemption. The formula builder requires a fallback value. The fallback value is used if the dynamic formula cannot be evaluated due to missing parameters.

Application scope

Dynamic formulas can be used as follows.

Dynamic discount formulas

The dynamic discount formula builder applies to:
  • Order discount
  • Product discount
  • Reward
Used in:
  • Coupon campaigns
  • In-cart promotions
  • Referral codes

Dynamic points formulas

The dynamic points formula builder applies to:
  • Fixed earning rules
  • Proportional earning rules
Used when creating loyalty programs.
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).
If the item price is 6.00, the discount is 1.06.
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.
The cheapest order item is determined as follows when there are several items with the same price.
  1. 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.
  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.
  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.
The most expensive order item is determined as follows when there are several items with the same price.
  1. 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.
  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.
  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.
Give a customer 20% off when:
  • they have more than 10 store visits
  • AND the purchase occurs on Friday
Otherwise they receive 3% discount.

OR operator

At least one condition must evaluate to true.
Example use case:Give a customer 20% off when:
  • they have more than 10 store visits
  • OR the purchase occurs on Friday
Otherwise they receive 3% discount.

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.
Example logic:
  • 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.
Example:
  • Boston customers get 10% discount
  • New York customers get 15% discount
  • Customers from other locations get 5% discount
Last modified on June 22, 2026