Formula
Formula pricing calculates a charge from an arithmetic expression you write, using the customer’s own answers as variables. It is available on text and numeric options.
Use it when the price is a calculation rather than a lookup: price per square metre, price per centimetre of length, a rate that depends on two dimensions.
Variable names
Section titled “Variable names”Each option in the set is available as a variable, named from its label: lowercased, with every run of non-letters and non-digits turned into a single underscore.
| Option label | Variable |
|---|---|
Length |
length |
Length (cm) |
length_cm |
Width in mm |
width_in_mm |
The admin shows you the generated names as you build the set. Renaming an option changes its variable name, so update any formula that referenced it.
What you can write
Section titled “What you can write”Four operators, parentheses, numbers and variables:
length_cm * 0.40(width_cm * height_cm) / 10000 * 25base_price * 0.15 + 2| Supported | Not supported |
|---|---|
+ - * / |
Functions (min, round, sqrt) |
| Parentheses | Comparisons and conditionals |
| Negative numbers | Loops, variables you assign |
There is deliberately no function library. The expression runs inside Shopify’s checkout function under a strict time budget, and the limits below exist so a formula cannot exhaust it:
- At most 200 characters
- At most 100 tokens
- At most 16 levels of nested parentheses
If you need a conditional price, model it with a choice option plus conditional logic rather than trying to express it arithmetically.
Worked example: price by area
Section titled “Worked example: price by area”A made-to-measure panel priced at £25 per square metre, from two numeric options Width cm and Height cm:
(width_cm * height_cm) / 10000 * 25| Width | Height | Area | Added |
|---|---|---|---|
| 100 | 100 | 1.00 m² | £25.00 |
| 150 | 80 | 1.20 m² | £30.00 |
| 200 | 250 | 5.00 m² | £125.00 |
Bound both inputs. Without a maximum, a customer entering 9999 in both produces a cart line in the tens of thousands.
When a formula cannot be calculated
Section titled “When a formula cannot be calculated”A formula that cannot be evaluated — a typo, a variable that no longer exists, a division by zero — adds nothing. It does not guess, and it does not block the sale.
This is a deliberate safety choice: inventing a charge from an expression the app does not understand is worse than charging nothing. But it does mean a broken formula is silent on the storefront. Always check a worked example on a real product page after editing one, rather than trusting that the form saved.
Rounding
Section titled “Rounding”The whole expression is evaluated in fractions of a penny and rounded half-up once, at the end. Intermediate steps are not rounded, so (3 / 7) * 7 gives back 3.