Conditional Logic

Conditional Logic

Conditional logic lets you dynamically show or hide calculator fields, add surcharges, and switch formulas based on customer input. This is useful for products where the pricing or fields change depending on what the customer enters.

Overview

A condition consists of:

  • When: Which input field to watch (e.g., width, height, a custom variable)
  • Operator: How to compare (e.g., greater than, equals)
  • Value: The threshold value
  • Then: What action to take
  • Target: What the action applies to
Conditions are evaluated in real time as the customer enters measurements. They also run server-side when the product is added to the cart.

Setting up conditions

  • Go to the Measurement tab on any product.
  • Scroll down to the Conditional Logic section.
  • Click Add Condition.

Condition fields

FieldDescription
WhenThe input field to evaluate. Populated from the calculator type's input fields and any custom variables
OperatorComparison operator
ValueThe threshold value to compare against
ThenThe action to take when the condition is true
TargetThe field or value the action applies to
Scroll to see all columns →

Available operators

OperatorDescriptionExample
>Greater thanWidth > 10
>=Greater than or equalArea >= 100
<Less thanHeight < 3
<=Less than or equalWeight <= 50
==EqualsLength == 8
!=Not equalsWidth != 0
Scroll to see all columns →

Available actions

ActionDescriptionTarget
Show fieldReveals a hidden input fieldField name to show
Hide fieldHides a visible input fieldField name to hide
Add surcharge (%)Adds a percentage surcharge to the total pricePercentage value
Add surcharge (fixed)Adds a fixed amount to the total priceDollar amount
Use formulaSwitches to a different formulaFormula expression
Scroll to see all columns →

Action types explained

Show field

Reveals a calculator input field that starts hidden. The field animates into view when the condition is met and hides again when it's not.

Example: Show a "Depth" field only when the width is greater than 10 feet.

WhenOperatorValueThenTarget
width>10Show fielddepth
Scroll to see all columns →
Setup: The target field must exist as a variable or input. Fields with show conditions start hidden by default.

Hide field

Hides a visible input field when the condition is met.

Example: Hide the "Height" field when the customer selects a specific option.

WhenOperatorValueThenTarget
product_type==flatHide fieldheight
Scroll to see all columns →

Add surcharge (percentage)

Adds a percentage surcharge on top of the calculated price.

Example: Add a 15% surcharge for oversized items (area over 500 sq ft).

WhenOperatorValueThenTarget
width>20Add surcharge (%)15
Scroll to see all columns →
The surcharge is displayed as a separate line in the calculator results:
  • "Oversize surcharge: +15% ($45.00)"

Add surcharge (fixed)

Adds a flat dollar amount to the total price.

Example: Add a $25 setup fee for orders where the length exceeds 50 feet.

WhenOperatorValueThenTarget
length>50Add surcharge (fixed)25
Scroll to see all columns →
The surcharge is displayed as a separate line:
  • "Setup fee: +$25.00"

Use formula

Switches the calculation to a completely different formula when the condition is met.

Example: Use a different formula for round vs rectangular cuts.

WhenOperatorValueThenTarget
shape==roundUse formula3.14159 * radius * radius
Scroll to see all columns →
Important: The alternative formula can reference any variables defined in the custom variables table. Make sure all variables used in the formula exist.

Multiple conditions

You can add multiple conditions to a product. They are all evaluated independently on every input change.

Stacking surcharges

Multiple surcharge conditions can stack. If two surcharges are both true, both are applied.

WhenOperatorValueThenTarget
width>20Add surcharge (%)10
length>30Add surcharge (%)5
Scroll to see all columns →
If width is 25 and length is 35, both surcharges apply: 10% + 5% = 15% total surcharge.

Multiple show/hide conditions

If multiple conditions target the same field, the last matching condition wins.

Frontend display

Surcharges

When surcharge conditions are active, a surcharges section appears below the calculator results showing each active surcharge with its label and amount.

Hidden fields

Fields with show conditions start hidden. When the condition becomes true, the field slides into view with a smooth animation. When the condition becomes false again, it slides back out.

Formula switching

When a "Use formula" condition activates, the calculation switches instantly. The customer sees the updated price without any page reload.

Server-side validation

All conditions are also evaluated on the server when the product is added to the cart. This ensures:

  • Surcharges can't be bypassed by manipulating client-side JavaScript.
  • The cart price always matches what the customer saw on the product page.
  • Formula switching produces the same result server-side.

Example: custom window blinds

A window blinds product where oversized windows cost more:

Calculator type: Area (L×W)

Variables: Width (in), Height (in)

WhenOperatorValueThenTarget
width>72Add surcharge (%)20
height>84Add surcharge (%)15
width>96Add surcharge (fixed)50
Scroll to see all columns →
Result: A 100" × 90" window:
  • Base area price calculated normally
  • +20% surcharge (width > 72)
  • +15% surcharge (height > 84)
  • +$50 flat fee (width > 96)

Example: material-dependent formula

A product where the calculation changes based on material type:

Calculator type: Custom Formula

Variables: length, width, material (dropdown: "standard", "premium", "heavy-duty")

Default formula: length * width

WhenOperatorValueThenTarget
material==premiumAdd surcharge (%)25
material==heavy-dutyUse formulalength * width * 1.5
Scroll to see all columns →

Best practices

  • Keep conditions simple. One or two conditions per product is usually enough.
  • Test all branches. Enter values that trigger each condition and verify the result.
  • Use clear surcharge descriptions. Customers should understand why they're paying more.
  • Don't overuse formula switching. If you need many different formulas, consider separate products.
  • Set appropriate min/max constraints on fields to limit the range of conditions that can trigger.

Troubleshooting

Condition not triggering

  • Check the "When" field matches the exact variable name (case-sensitive).
  • Verify the operator and value are correct.
  • Make sure the customer's input actually satisfies the condition.

Surcharge not applied in cart

  • Server-side condition evaluation uses the same logic. Check that the cart's stored measurement values match.
  • Verify the condition is saved on the product (reload the product editor).

Show/hide field not working

  • The target field name must exactly match a variable name in the custom variables table or a built-in input field name.
  • Check for JavaScript errors in the browser console.