Help CenterFormula Pricing

Formula syntax reference

Available variables

Variable Description Source
cost Cost per item Shopify product.cost_per_item
price Current selling price Shopify variant.price
compare_at_price Current compare-at price Shopify variant.compare_at_price
shipping_cost Custom shipping cost (if set in metafield) Metafield: bulkops.shipping_cost
packaging_cost Custom packaging cost (if set in metafield) Metafield: bulkops.packaging_cost

Operators

Operator Description Example
+ Addition cost + 5
- Subtraction price - 10
* Multiplication cost * 2.5
/ Division cost / 0.6
% Modulo price % 10

Functions

Function Description Example
round(x, n) Round to n decimal places round(cost * 2.5, 2)
ceil(x) Round up to integer ceil(cost * 2.5)
floor(x) Round down to integer floor(cost * 2.5)
min(x, y) Minimum of two values min(cost * 2, 99)
max(x, y) Maximum of two values max(cost * 2, 19.99)
abs(x) Absolute value abs(price - cost)

Conditional expressions

Use ternary syntax for conditions:

condition ? value_if_true : value_if_false

Examples:

cost < 20 ? cost * 4 : cost * 2.5
cost > 100 ? cost * 1.8 : cost * 2.2

Conditions support: <, >, <=, >=, ==, !=, &&, ||

Common formula patterns

Simple markup:

cost * 2.5

Gross margin target (40%):

cost / (1 - 0.40)

Full cost stack with target margin:

(cost + shipping_cost + packaging_cost) / (1 - 0.40)

Tiered markup by cost range:

cost < 10 ? cost * 4 : cost < 50 ? cost * 3 : cost * 2.2

Price floor — never price below $19.99:

max(cost * 2.5, 19.99)

Price cap — never price above $499:

min(cost * 2.5, 499)

Error messages

Error Cause Fix
Unknown variable: X Typo in variable name Use cost, price, etc.
Division by zero Formula divides by zero Add a guard: cost > 0 ? cost / x : 0
Cost data missing Product has no cost set Add cost in Shopify admin
Result is negative Formula produces negative price Check your expression logic

Ready to try it?

Add BulkOps.ai to your Shopify store — free plan available, no credit card required.

Add to Shopify — Free

Was this helpful?