The formula editor appears throughout the calculator editor wherever a calculation is needed — option pricing, variables, fixed fees, price adjustments, weight, and the total price formula. You can find formula fields in Calculator Editor → Options & Pricing. Each formula editor has four modes accessible via tabs at the top: Manual (type formulas directly), Describe with AI (generate a formula from plain English), Explain formula (get a plain-English breakdown of an existing formula), and Troubleshoot (run the formula for a set of choices, see the value of every part, and find out why the result is not what you expected).
These functions pull values from options, variables, and tables into your formulas. All string arguments must use double quotes — OPT("WIDTH") is correct, OPT(WIDTH) is not.
| Function | Description |
|---|---|
OPT("KEY") |
The option's computed value — the result after any formula on that option has run. For switch options, returns TRUE or FALSE. |
OPT_TOKEN("KEY") |
The selected Choice Token for a dropdown/radio/button/swatch (not the display label). Use this with TABLE() lookups (as a row key and/or column key) or IF comparisons. Empty when nothing is selected. |
INPUT("KEY") |
The raw value the customer entered. Only works for numeric-like options: number, slider, length, area, volume, and weight. Not for quantity — use OPT("KEY") for the resolved count. |
INPUT("KEY", "dim1") |
A single dimension from a dimensions option. Use the stable tokens "dim1", "dim2", "dim3" for each dimension in order. |
INPUT("KEY", "area") |
Total area of a Room map option. 0 until each counted room is closed. Also "perimeter" (all walls, including open rooms) and "rooms" (rooms with at least one wall length). There is no per-wall token. OPT("KEY") is the option price, not the area. |
VAR("KEY") |
A calculator variable defined in the Variables section. Also: VAR("BASE_PRICE") — your Initial Price base in dollars (fixed or variant). System / product variables: VAR("SHOPIFY.PRICE"), VAR("SHOPIFY.UNIT_PRICE"), VAR("SHOPIFY.QUANTITY"), and VAR("META....") metafield aliases where configured. |
HAS("OPTION_KEY", "CHOICE_KEY") |
Returns TRUE when a choice option (dropdown, radio, button, checkbox group, swatch, image swatch, switch) has the specified value selected. |
COUNT("OPTION_KEY") |
The number of selected values (0 to N) in a multi-select option such as a checkbox group. |
CHARCOUNT("KEY") |
The character count of a text or textarea option's input. Use this instead of LEN(INPUT(...)). |
TABLE("name", key) / TABLE("name", rowKey, colKey) |
Looks up a value from a pricing table. One key for one-column (key→value) tables; row + column keys for multi-column grids. Keys can be numbers (INPUT) or Choice Tokens (OPT_TOKEN). Optional fourth argument sets match mode: "exact", "nearestLower", "nearestUpper", "nearest", or "interpolate" (one-column numeric tables). |
OPT vs. OPT_TOKEN vs. INPUT: Use
INPUTfor the raw entered value (dimension math, unit conversions). UseOPTfor the option's computed / priced result after its own formula has run. UseOPT_TOKENfor the selected Choice Token when looking up or comparing choices — never useOPTas a table key for dropdown/radio/button/swatch options.
Capitalization does not matter for names. Option keys, variable names, pricing table names, Choice Tokens in
HAS, and dimension names inINPUT("KEY", "dim1")match regardless of case:OPT("area"),OPT("Area"), andOPT("AREA")all read theAREAoption, andTABLE("pricing", …)finds a table namedPricing. If two names differ only by case, the exact spelling wins. Function names are case-insensitive too.
| Operator | Description |
|---|---|
+ - * / |
Add, subtract, multiply, divide |
% |
Modulo (remainder) |
^ or ** |
Exponent (power) |
== != |
Equal, not equal |
< <= > >= |
Comparison |
&& |
Logical AND |
|| |
Logical OR |
( ) |
Group expressions to control evaluation order |
| Function | Description |
|---|---|
IF(condition, then, else) |
Returns then when condition is true, otherwise else. |
AND(a, b, ...) |
Returns TRUE when all arguments are true. |
OR(a, b, ...) |
Returns TRUE when at least one argument is true. |
NOT(x) |
Returns TRUE when x is false, and vice versa. |
| Function | Description |
|---|---|
ABS(x) |
Absolute value of x. |
MIN(a, b, ...) |
Returns the smallest value. |
MAX(a, b, ...) |
Returns the largest value. |
CLAMP(x, min, max) |
Bounds x between min and max. |
SQRT(x) |
Square root of x. |
POWER(x, y) / POW(x, y) |
Raises x to the power of y. |
EXP(x) |
e raised to the power of x. |
ROOT(x, n) |
Nth root of x. |
SIGN(x) |
Returns -1, 0, or 1 depending on the sign of x. |
SUM(a, b, ...) |
Adds all arguments. Non-numbers are treated as 0. |
| Function | Description |
|---|---|
ROUND(x, n) |
Rounds x to n decimal places. |
CEILING(x) |
Rounds x up to the nearest integer. |
FLOOR(x) |
Rounds x down to the nearest integer. |
TRUNC(x, n) |
Truncates x to n decimal places without rounding. |
| Function | Description |
|---|---|
LEN(text) |
Number of characters in text. |
CONCAT(a, b, ...) |
Concatenates values together as a string. |
The default mode. Type your formula directly into the editor. The formula is checked as you type, the calculator's live Preview column shows the resulting price, and the Troubleshoot tab shows the value of each part. The editor supports autocomplete — as you type, it suggests option keys, variable names, and function names.
Switch to the Describe with AI tab to generate a formula from a plain-English description:
The AI uses your calculator's current options and variables as context, so it can reference them by name.
Describe with AI writes formulas only. A dollar extra (“Rush is $15”) belongs in the formula. A store product you want added to the cart (hanger, gift wrap) is an add-on product — link it on the choice with Add to cart. Do not also put that product’s price in the formula. Which names appear on the cart line is Cart properties, not a formula.
Switch to the Explain formula tab when you have an existing formula you want to understand:
This is useful when reviewing formulas written by someone else, or when revisiting a complex formula you wrote previously.
Switch to the Troubleshoot tab when a formula returns a number you did not expect — a table lookup that comes back as 0, a surcharge that never applies, a total that is off. The tab runs the formula with the same engine the storefront uses and shows you what every part of it is worth, so you can see exactly where the number goes wrong.
OPT_TOKEN(), HAS() and table lookups use. Reset to storefront defaults puts the preview back to what a customer sees when the page loads.OPT() used where OPT_TOKEN() was meant, INPUT() on a quantity option (always 0), a table mode that misses keys between tiers (with what each other mode would return), a Rate other than 1 multiplying the formula, or an IF whose condition is never true for this scenario. For an option formula the tab also tells you when the storefront would not use the formula at all in that scenario — the option has nothing selected, the value is out of range, a visibility rule (named) or the eye toggle hides it, a different choice is selected, or a value rule replaces the result. The result block then shows what the storefront charges for the option, the reason in one sentence, and what this formula would return if it applied. When you opened the formula of a choice that is not selected, the tab says which choice is selected instead and one click selects this one — in the preview too.IF show whether that branch was taken, and table lookups show the row and column that were tried, whether they hit, and the closest keys when they missed. The circled chevron beside an issue's title opens Step by step, scrolls it into view, and highlights the step it came from.Two shortcuts open this tab for you:
The tab reads your current draft, so you can change the formula, a Choice Token, a table, or a rule and see the new result immediately — nothing is saved until you save the calculator.
Describe with AI, Explain formula, and the Explain this result button on the Troubleshoot tab consume AI credits from your plan allowance. The rest of the Troubleshoot tab — the scenario, the step-by-step values, and the likely issues — runs in your browser and is free. Simple requests use fewer credits than complex ones. Monitor your usage on the Subscription page.
Area-based pricing — multiply two dimension inputs to get square footage, then apply a rate:
INPUT("WIDTH") * INPUT("HEIGHT") * 0.50
Dimensions option — calculate area from sub-dimensions and convert square inches to square feet:
INPUT("DIMENSIONS", "dim1") * INPUT("DIMENSIONS", "dim2") / 144
Room map — charge per square foot of closed rooms, with 10% waste:
INPUT("ROOM", "area") * 1.1 * 4.50
Using a variable — reference a calculator variable in the total formula and add option contributions:
VAR("AREA") * 50 + OPT("MOTOR") + OPT("FINISH")
Conditional pricing with HAS — charge a premium rate when a specific material is selected:
IF(HAS("MATERIAL", "PREMIUM"), VAR("AREA") * 1.25, VAR("AREA"))
Table lookup — pull a per-square-foot rate from a pricing table:
TABLE("price_per_sqft", INPUT("WIDTH"), INPUT("HEIGHT"))
One-column table lookup — key→value material rate keyed by Choice Tokens (column header can be omitted when there is only one value column):
TABLE("materials", OPT_TOKEN("MATERIAL"))
Multi-column lookup with a Choice Token column key — numeric size in the blue column, material tokens across the green header row:
TABLE("sheet_prices", INPUT("SIZE"), OPT_TOKEN("MATERIAL"))
Table lookup with interpolation — linear interpolation on a one-column numeric table (mode as the fourth argument when a column key is present):
TABLE("rates", INPUT("LENGTH"), "Price", "interpolate")
Minimum price enforcement — set a $25 price floor:
MAX(25, OPT("QTY") * 2.50)
Multi-select surcharge — add $5 for each topping selected:
COUNT("TOPPINGS") * 5
Per-character pricing — charge per character of engraving text:
CHARCOUNT("ENGRAVING_TEXT") * 0.75
OPT vs. INPUT — INPUT("LENGTH") is the raw number the customer typed, while OPT("FINISH") is the dollar amount computed by the Finish option's formula:
INPUT("LENGTH") * 2 + OPT("FINISH")
Shopify variant price — start from the storefront variant price and add option contributions:
VAR("SHOPIFY.PRICE") + OPT("SIZE") + OPT("COLOR")
Calculator initial price (base) — same idea using the configured Initial Price (fixed or variant) via VAR("BASE_PRICE"):
VAR("BASE_PRICE") + OPT("SIZE") + OPT("COLOR")
See Initial Price (Base Price) for when to prefer BASE_PRICE vs SHOPIFY.PRICE.
Describe with AI — You type: "Price is width times height times $3.50 per square foot, minimum $50." The AI returns: MAX(50, INPUT("WIDTH") * INPUT("HEIGHT") * 3.50).
Explain formula — You paste IF(HAS("FINISH", "MATTE"), VAR("AREA") * 4.25, VAR("AREA") * 3.75) and switch to Explain formula. The AI responds: "If the Finish option is set to Matte, multiply the area by $4.25; otherwise multiply by $3.75."
Troubleshoot — The preview shows $0 for a 3000 × 2500 sheet. You click Price looks wrong? (or open the formula's Troubleshoot tab) and type 1618.92 in I expected. Likely issues names the problem: Width's Choice Token is 2300, which is not a column in the planar table. The Fix block offers Set token to "3000"; after you click it, the preview shows $1618.92.