Skip to main content
Use dynamic formulas to calculate discounts, product units, replacement units, or loyalty points based on order, customer, item, metadata, or campaign-related values.
For supported operands, functions, operators, and expression syntax, see Dynamic formula reference.
The formula builder helps you create formulas by typing them directly, selecting variables, metadata, functions, and operators, using templates, or working in the diagram view. Templates provide starting points for common logic, such as calculations based on order amount, customer metadata, or order currency. The formula field shown in the builder depends on the selected discount type, product discount setup, or earning rule configuration. Before you create a formula, the required value field uses the label of the configured value. After you create a formula, this field changes to Fallback and is used when the formula cannot be calculated.
Amount formula fields are shown when the selected configuration calculates a monetary value.Formula fields:
  • Discount Amount formula: calculates the discount amount
  • Fixed amount formula: calculates the fixed discount amount
  • New price formula: calculates the new product price
Example formula:
IF(ORDER_AMOUNT > 200;ORDER_AMOUNT * 0.15;ORDER_AMOUNT * 0.05)

Type a formula

Type or paste a formula directly into the formula field. Use the supported expression syntax. For example, to return a different value depending on the order amount, enter:
IF(ORDER_AMOUNT > 100;15;5)

Add formula elements

Select the formula field to show the formula toolbar. Use the toolbar to add formula elements. Available controls:
  • Add variable: Adds predefined operands, such as order, customer, or item values.
  • Add metadata: Adds metadata operands.
  • IF: Adds conditional logic.
  • SWITCH: Adds switch logic.
  • +: Adds an operator.
  • Add FUNCTION: Adds a function.
  • Templates: Opens predefined formula templates.
After adding an element, fill in the required arguments in the formula field, such as metadata keys, comparison values, or values returned by conditional logic.

Use templates

Open Templates and click a template. Available templates:
  • Based on order amount: Creates formula logic based on the order amount.
  • By customer metadata condition: Creates conditional formula logic based on customer metadata.
  • By customer metadata value: Creates formula logic that uses a customer metadata value.
  • By order currency: Creates formula logic based on the order currency.
Templates add predefined formula logic that you can modify after inserting it. After selecting a template, update the generated values and conditions to match your promotion or loyalty logic.

Use the diagram view

Click Show diagram to open the formula in a diagram view. If the formula field is empty, the diagram view shows Click to add and template shortcuts. Use Click to add to start creating the formula visually, or select one of the displayed templates. If a formula is already defined, the diagram view shows the formula as connected nodes and keeps the editable expression below the diagram. In the diagram view, you can also use:
  • Formula toolbar and inline formula editor: Add or edit formula elements without leaving the diagram view.
  • Zoom controls: Adjust the diagram view.
You can use the diagram view to inspect existing logic and add new conditions or cases directly to the formula.

Format, validate, and save

Use Format to format the expression. Available options:
  • Format now: Formats the current formula
  • Auto-format: Reformats the formula automatically while editing
To remove the formula, click Clear. Review the validation message below the formula editor. If the formula is correct, the builder shows Formula is valid. Click Save to save the discount configuration or earning rule. After the campaign is saved, you can edit the formula by editing the campaign from the campaign view.
Last modified on June 17, 2026