Formula pricing is available on Shopify, and on WooCommerce from plugin
version 0.4.16.
When to use a formula
Reach for a formula when:- your price list is already a spreadsheet formula,
- the price depends on the size and the quantity together, as with custom-size signs, banners and panels,
- each item has a minimum price, whatever its size, or
- you price in size bands and want quantity to count as well.
How a formula rule works
A formula is a price rule like any other, so it lives in the same places:- On a field (its Pricing tab): it applies while that field is shown. A formula on the size field is the usual choice.
- On a choice (open the choice’s details, then Pricing): it applies while that choice is selected. Give each material its own formula when aluminium and foam board are priced differently.
qty
in the formula wherever the quantity matters.
Everything else in your option set still applies around it: the base price
is added, a choice’s percentage (a rush surcharge, say) applies to the
running total after it, and setup fees and the minimum price come last.
To let the formula be the whole price, set the base price to 0, once per
order.
Your first formula: custom-size signs
This walk-through builds the sign price from the top of this page. Each sign size has three numbers, all worked out from the sign’s area in square feet:- Add the size. Add a Dimensions field labelled Size, with inches as its unit. (The Posters template already has one, in centimetres.)
- Zero the base price. Under Product settings, set the base price to 0, charged Once per order.
- Add the rule. Select the Size field, open its Pricing tab,
click + Add price rule, and change the rule’s type to Formula.
A starter formula,
10 * area * qty, appears. - Set the units. Size from is the field the formula reads (Size). Set w and h in to in and area in to ft². The builder picks these for you from the size field: inches go with square feet, centimetres with square metres.
- Add the steps. Click + Add step three times, and fill in the
names and formulas from the table above:
P1=25 + 6 * area,F=4 + 3.5 * area,b=8 + 2 * area. - Write the price. In Price =, enter
P1 + F * (qty - 1) + b * (1 - 0.25^(qty - 1)) / 0.75. - Check it. Open Check prices, enter a size such as 24 × 18, and compare the table with your own price list (see Checking your prices).
- Publish.
Writing formulas
Names you can use
- Names don’t care about capitals:
Qty,QTYandqtyare the same. w,handareaare 0 until the customer has entered a size. If the rule’s Size from is set to Uploaded file canvas, they come from the artwork’s own size instead of a dimensions field.
Operators
Two things a spreadsheet lets you do that a formula doesn’t:
- Write the multiplication.
2 * area, not2area. - Bracket a negative power. Spreadsheets read
-2^2as 4, maths reads it as −4. To avoid surprises the builder asks you to write(-2)^2or-(2^2).2^-1(a negative exponent) is fine as it is.
Functions
band() works like a price-break table: it checks the limits from left to
right and gives the value of the first band that x fits under (each limit is
included in its band), or the last value when x is above them all.
band(area, 2, 30, 6, 26, 22) is 30 up to 2 ft², 26 up to 6 ft², and 22
above that.
From a spreadsheet
Pasting a formula from a spreadsheet or a document works: the builder turns× into * and − or – into - as you paste. Spreadsheet functions
translate like this:
Limits
- Up to 10 steps, and up to 500 characters per step or price.
- A step name starts with a letter and then uses letters, digits or
_(up to 32 characters). It can’t reuse a name the formula already has, such asarea,qtyormax. - Only letters, digits, spaces and
_ . , + - * / ^ ( )are allowed. There are no comparisons (<,>) and noif: usemin,maxandbandinstead. (WordPress would rewrite<,>and%when your option set is saved, so they are kept out of formulas on every platform.) - A formula rule has no volume breaks of its own. Put the breaks in the
formula with
band(). - A formula can’t go on one option of a
quantity per option
field. Put it on the field itself, where
qtyis the total.
Units
w and h in and area in are separate on purpose. A US sign shop measures in inches and prices by the square foot: with in and ft², a 24 × 18 in sign reads asw = 24, h = 18 and area = 3. The customer can
enter the size in any unit the size field offers. The formula always sees it
converted into your units.
Sizes are converted exactly as you would expect on paper. A 12 in width is
12 in the formula, not 11.999…, so
floor(w) and band() limits behave.
Checking your prices
Check prices, under the formula, shows what the rule charges at one size for several quantities: the quantity field’s presets if it has some, otherwise 1, 2, 5, 10 and 25. This rule adds is the rule’s total; Each is that divided by the quantity. It uses the same calculation as your storefront. The table shows this rule only. Other rules (a material surcharge, a rush percentage, a setup fee, the minimum price) still apply on top, and the Preview pane on the right shows the whole product as your customers will see it.When the builder flags a formula
Mistakes show in red under the step or price they are in, as you type, and the option set can’t be published until they are fixed:When a formula has no price
Some formulas have no answer for some jobs: dividing byqty - 1 when one
sign is ordered, or sqrt of a negative number. The configurator then tells
the customer This size can’t be priced online. Please contact us. and won’t
add the job to the cart. A job is never sold at a price of 0 because a formula
broke.
To keep every size priceable, give the size field a minimum and maximum
width and height, and guard any division, for example
100 / max(qty - 1, 1).
Recipes
A minimum price per item
A minimum price per item
A per-area price undercharges small items. This charges $12.99 per square
foot, but never less than $30 a sign:Ten 9 × 12 in signs (0.75 ft² each) cost $300 rather than $97.40.
Size bands
Size bands
$30 a sign up to 2 ft², $26 up to 6 ft², $22 above:
Per started square foot
Per started square foot
Round the area up before pricing it, so 2.25 ft² is billed as 3:
Edge finishing by the perimeter
Edge finishing by the perimeter
Hemming or edge banding is priced by the length around the item. With
w and h in set to ft:
A discount that grows with quantity
A discount that grows with quantity
0.1% off per item ordered, capped at 30%:
Setup plus run
Setup plus run
A $35 setup and $0.80 per item, as one rule:(A setup fee under Product settings does the same for the setup part,
and is never scaled by percentages or multipliers.)
Booklets by the sheet
Booklets by the sheet
Four pages fit on one sheet, and a started sheet is a whole sheet. With a
file upload that reports the page count:
A different formula for each material
A different formula for each material
Put a formula rule on each material choice instead of on the size field:
only the selected material’s formula applies.
Questions
Can a formula use other fields' answers?
Can a formula use other fields' answers?
Not yet: a formula reads the quantity, the size and the page count. For
choices such as material or finish, put a formula (or a percentage) on
each choice instead.
Can a customer change the price the formula gives?
Can a customer change the price the formula gives?
No. The configurator shows a preview, and the same formula runs again on
our servers when the job is added to the cart. Your store charges the
price our servers calculate and sign, as with every other price rule.
The storefront total differs from Check prices. Why?
The storefront total differs from Check prices. Why?
Check prices shows the formula rule on its own. The storefront adds
the base price, other price rules on the selected choices, percentages,
setup fees and the minimum price. Set the base price to 0 if the formula
should be the whole price.
Does the 'Add 15 more to get 15% off' hint work with formulas?
Does the 'Add 15 more to get 15% off' hint work with formulas?
The hint reads quantity breaks, so a product priced only by a formula
doesn’t show it. See
the next price break.