Formula Editor

Formula Editor

Overview

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 three modes accessible via tabs at the top: Manual (type formulas directly), Describe with AI (generate a formula from plain English), and Explain formula (get a plain-English breakdown of an existing formula).

Quick Reference

Value Accessors

These functions pull values from options, variables, and tables into your formulas. All string arguments must use double quotesOPT("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.
INPUT("KEY") The raw value the customer entered. Only works for numeric-like options: number, slider, quantity, length, area, volume, and weight.
INPUT("KEY", "dim1") A single dimension from a dimensions option. Use the stable tokens "dim1", "dim2", "dim3" for each dimension in order.
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", rowKey, colKey) Looks up a value from a pricing table. Supports an optional fourth argument for match mode: "exact", "nearestLower", "nearestUpper", "nearest", or "interpolate".

OPT vs. INPUT: Use INPUT when you need the raw entered value — for dimension math or unit conversions. Use OPT when you need the option's computed result after its own formula has run.

Operators

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

Functions

Logic

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.

Math

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.

Rounding

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.

Text

Function Description
LEN(text) Number of characters in text.
CONCAT(a, b, ...) Concatenates values together as a string.

Details

Manual Mode

The default mode. Type your formula directly into the editor. The formula is evaluated in real time and the result appears in the live preview. The editor supports autocomplete — as you type, it suggests option keys, variable names, and function names.

Describe with AI

Switch to the Describe with AI tab to generate a formula from a plain-English description:

  1. Click the Describe with AI tab (sparkle icon) above the formula field.
  2. Describe what you want the formula to do in plain English — for example, "charge $2.50 per square foot with a $25 minimum."
  3. Click Generate. The AI produces a working formula using the correct syntax and your calculator's option keys.
  4. Review the generated formula and accept it, or refine your description and generate again.

The AI uses your calculator's current options and variables as context, so it can reference them by name.

Explain Formula

Switch to the Explain formula tab when you have an existing formula you want to understand:

  1. Click the Explain formula tab above a formula field that already contains a formula.
  2. The AI reads the formula and returns a step-by-step plain-English explanation of what it does and how it evaluates.

This is useful when reviewing formulas written by someone else, or when revisiting a complex formula you wrote previously.

AI Credits

Both Describe with AI and Explain formula consume AI credits from your plan allowance. Simple requests use fewer credits than complex ones. Monitor your usage on the Subscription page.

Examples

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

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"))

Table lookup with interpolation — get smoothly interpolated rates between table rows:

TABLE("rates", INPUT("LENGTH"), INPUT("WIDTH"), "interpolate")

Minimum price enforcement — set a $25 price floor:

MAX(25, INPUT("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. INPUTINPUT("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."

    • Related Articles

    • Total Price Formula

      Overview The Unit price calculation / Total price calculation field (this section is titled Total Price Formula in the nav) is the main place you define how the line price is computed from options and base. You can also set minimum and maximum price ...
    • Calculator Editor Overview

      Overview The calculator editor is the main workspace where you build and customize your product calculator. It is divided into three areas: a header bar at the top, a tabbed main panel in the center, and a live preview panel on the right. Together, ...
    • Pricing Variables

      Overview Pricing variables are named, computed values that act as intermediate steps in your pricing logic. Instead of writing one large formula, you can break the calculation into smaller, readable pieces — each stored as a variable — and reference ...
    • Weight Calculation

      Overview Weight calculation lets you define a formula that computes a product's shipping weight based on customer selections. The calculated weight is saved with the order so your shipping provider can use it to quote accurate rates. You configure it ...
    • Initial Price (Base Price)

      In the editor, this section is labeled Initial Price. The dropdown inside it is labeled Base price. Overview Initial Price sets the calculator’s base—the starting dollar amount the app uses before stacking option prices and (optionally) your Unit ...