Using the Formula Builder

Written By Floris de Vries

Last updated 3 days ago

The Formula Builder is where you define how the final price is calculated. It allows you to write mathematical formulas using field values, product prices, and helper functions.


Formula step tabs

Inside the Formula builder step you will see these tabs:

  • 4a. Custom variables – reusable intermediate formulas (_cv_…)

  • 4b. Lookup tables (Premium) – 2D price matrices via lookup2d(…)

  • 4c. Formula – the main price formula (or conditional if / then / else)

  • 4d. Calculation display (Premium) – configure storefront price breakdown rows


Formula editor

You can create formulas by:

  • Typing directly into the chip editor (click between chips to place the caret)

  • Inserting operators and variables with the buttons / dropdown above the editor — they insert at the caret, not always at the end

  • Pasting formulas from elsewhere

All formulas must result in a numeric value.


Supported operators

The following mathematical operators are supported:

  • + Addition

  • - Subtraction

  • × Multiplication

  • ÷ Division

  • ( ) Parentheses

Parentheses are strongly recommended to control calculation order and avoid unexpected results.


Field selector

The Form fields dropdown allows you to insert available variables directly into the formula.
This includes:

  • All fields created in Step 1

  • Custom variables (4a)

  • Lookup tables (4b, Premium) as lookup2d(…) chips

  • Product and variant metafields

  • Rounding / math helpers

Using the selector reduces typing errors and ensures valid variable names.


Writing clear formulas

Best practices for writing formulas:

  • Use parentheses to group calculations

  • Keep formulas readable and structured

  • Apply rounding at the end of the formula

  • Avoid unnecessary complexity

Example

(product_price + width * height) * material_multiplier

Conditional formulas (Premium)
For advanced pricing logic, you can switch to conditional formulas. This allows you to apply different formulas based on conditions such as size thresholds or selected options.

Learn more → Conditional Pricing (Premium)


💡 Tip:
If a formula becomes difficult to read, split logic into 4a. Custom variables, use a 4b. Lookup table for matrix pricing, or switch to conditional formulas in 4c.