Pro feature · WPConfigurator 3D Product Customizer 1.3.5 and later
A Formula layer works out a number from other layers, then either charges it or shows it. The customer doesn’t fill it in: it updates by itself as they change the layers it reads.
Use a Formula to:
- price by area, such as 45 per square metre of glass;
- price by length, such as trim around the edge of a window;
- add a surcharge only in some cases, such as on oversize openings;
- work out a count, such as how many panes a window needs;
- show a figure without charging for it, such as “Opening area: 1.80 m²” or a lead time.
A Formula usually reads Range layers, and can also read options, Color Pickers, groups, other fields and other formulas.
1. Turn on the Formula module
Formula is a module of its own. It’s off until you turn it on.
- In your WordPress dashboard, go to 3D Configurators → Modules.
- Find Formula and turn it on.
- Most formulas read Range layers, so turn on Custom Fields too.
- Optional: turn on Conditional Logic if you want rules that react to a formula result.
- Click Save.

2. Add a Formula layer
- Open your configurator in the editor, on the Model Structure tab.
- In the layer list, select the group the Formula belongs in.
- Click the Formula icon among the add-layer icons. Hover over an icon to see its name.
- A layer called Formula is added to the group. Rename it, for example to Glass.
- Select the layer. Its Formula Settings open in the settings panel.

A new Formula is empty, set to add its result to the price, and shows its result on the page.
Tip: Name the layer for what it works out. The page, the summary, the cart, emails and the PDF list a Formula by its layer name.
Formula Settings has five parts, in the order you fill them in:
| Part | What it’s for |
|---|---|
| Variables | The layers the formula reads, each with a short name. |
| Expression | The sum itself, such as {width} * {height} / 1000000 * 45. |
| Preview | Try the sum with values of your own. |
| Pricing | Whether the result is charged, or only shown. |
| Display | How the result looks on the page. |
3. Variables
A variable gives a layer a short name the expression can use.
- Under Variables, click Add Variable.
- Choose the Layer. The list shows every layer except this formula, with its group, such as “Size › Width”. Type to search it.
- Check the Name. If you haven’t typed one, it’s filled in from the layer’s name, so Width becomes
width. You can change it. A name uses letters, digits and underscores, and doesn’t start with a digit. - Choose what the variable Reads: the layer’s Value or its Price.

To remove a variable, click its ×.
What a variable reads
| Layer | Value | Price |
|---|---|---|
| Range | The number the customer set, on its scale | What the Range costs |
| Option or Color Picker | 1 when chosen, 0 when not | Its price, when chosen |
| Switch | 1 when on, 0 when off | Its price, when on |
| Checkbox | How many boxes are ticked | Its price, with the ticked choices’ prices |
| Select or Radio | The chosen choice’s Value, as a number | Its price, with the chosen choice’s price |
| Text Field or Text Area | The number the text starts with, so “12 mm” reads as 12 | Its price, when filled in |
| Group or Sub Group | How many of its items are chosen | What its chosen items cost together |
| Formula | Its result | Its result when it adds to the price, and 0 when it’s shown only |
- A layer the customer hasn’t chosen reads 0: an option they didn’t pick, a switch that’s off, an empty text field.
- Price is what the layer costs at that moment, with its sale price when that’s lower.
- Give choices numbers. For a Select or Radio to be read as a number, give each choice a number as its Value, such as 1, 2 and 3, or a rate such as 45. A choice whose Value is text reads 0. Check each Value after typing the Label: when a choice’s Value is empty, the editor fills it with the Label as soon as you leave the Label box, so a choice labelled Triple gets the Value “Triple” unless you change it.
- Use a Select or Radio field for a choice that carries a number. A group of options isn’t a Select: its Value is how many of its options are chosen, usually 1.
- A group’s Price includes its sub groups, and any Formula inside it that adds to the price. So put a Formula that reads a group’s Price outside that group. Inside it, the formula reads itself and gives 0.
- Ranges and Formulas are always chosen, so a group’s Value counts them too. To count options, give them a group or sub group of their own.
- Write numbers plainly in text fields. “1,200” reads as 1, because the comma stops it.
4. Expression
Write the sum in the Expression box. Put each variable’s name in curly braces, such as {width}. Click a name under Insert to add it at the end.
{width} * {height} / 1000000 * 45
The box colours each variable to match its row, and checks the sum as you type. Under it, you’ll see Valid, or a list of what to fix.

Arithmetic
| Write | Meaning | Example | Gives |
|---|---|---|---|
+ - | Add, subtract | {width} + 100 | 1300 when width is 1200 |
* / | Multiply, divide | {width} / 1000 | 1.2 when width is 1200 |
% | The remainder after dividing | {qty} % 6 | 2 when qty is 14 |
^ | To the power of | {side} ^ 2 | 9 when side is 3 |
( ) | Work this part out first | ({width} + {height}) * 2 | The perimeter |
Comparisons and logic
A comparison gives 1 when it’s true and 0 when it isn’t. Use them inside if(), or on their own.
| Write | Meaning |
|---|---|
< <= | Less than, less than or equal to |
> >= | Greater than, greater than or equal to |
= != | Equal to, not equal to. == and <> work too. |
and | Both are true |
or | At least one is true |
not(x) | 1 when x is 0, and 0 otherwise |
Any number except 0 counts as true.
Functions
| Function | What it gives | Example | Gives |
|---|---|---|---|
if(test, a, b) | a when the test is true, b when it isn’t | if({width} <= 1000, 20, 35) | 20 at 900 |
min(a, b, …) | The smallest | min({qty}, 10) | 10 when qty is 12 |
max(a, b, …) | The largest | max({price}, 60) | 60 when price is 45 |
clamp(x, low, high) | x, kept between low and high | clamp({x}, 10, 20) | 20 when x is 25 |
round(x) | x to the nearest whole number | round(2.5) | 3 |
round(x, places) | x to that many decimal places | round({area}, 2) | |
ceil(x) | x rounded up | ceil({width} / 1000) | 3 when width is 2350 |
floor(x) | x rounded down | floor(7.9) | 7 |
abs(x) | x without its minus sign | abs({a} - {b}) | |
sqrt(x) | The square root of x | sqrt({area}) | |
not(x) | 1 when x is 0, and 0 otherwise | not({express}) |
round() takes halves away from zero: round(2.5) is 3 and round(-2.5) is −3.
Order
The parts of a sum are worked out in this order:
- brackets and functions;
^, from right to left, so2 ^ 3 ^ 2is2 ^ 9;- a minus sign in front of a number, so
-2 ^ 2is −4 (write(-2) ^ 2for 4); *,/and%;+and-;- comparisons;
and;or.
Operations of the same rank go from left to right. Use brackets whenever you’re unsure.
Rules
- Lowercase only.
if,and,or,not,minand so on.IFandANDaren’t recognised. - Names exactly as written in Variables, with nothing else between the braces:
{width}, not{ width }. - Numbers use a point for decimals, with a digit before it:
0.5, not.5or0,5. Leave out thousands separators, currency signs and units. - One comparison at a time. Write
{w} > 100 and {w} < 200, not100 < {w} < 200. - Spaces and line breaks are fine between the parts.
- Up to 500 characters, and up to 10 levels of brackets and functions inside each other.
- Only these characters are kept: the letters A to Z without accents, digits, spaces and
_ { } . , ( ) + - * / % ^ < > = !. Anything else is saved as?, which the editor flags as an error.
Sums that can’t go wrong
A formula never stops the page or the checkout. Instead:
- dividing by 0 gives 0;
- the square root of a negative number gives 0;
- a name with no variable gives 0;
- an expression with an error gives 0;
- formulas that read each other in a loop all give 0.
The editor flags an expression with an error and a name with no variable, so you can put them right before customers see them. The others depend on the customer’s values or on other formulas, so the editor can’t spot them in advance.
5. Preview
Preview appears once the formula has a variable. Type a test value for each variable to see what the expression gives. Nothing here is saved, and customers never see it.
The Preview shows the exact result. A charged result is rounded to your store’s decimal places, so a Preview of 18.900000000000002 is charged as 18.90.

6. Pricing and Display
Pricing
| Result | What happens |
|---|---|
| Add to the price | The default. The result is this layer’s price, and is added to the total. It’s rounded to your store’s decimal places. A result below 0 is charged as 0: a formula can’t give a discount. |
| Show only | The result is shown, but never charged. Use it for a figure the customer should see, such as an area, a weight or a lead time, or for a step another formula reads. |
Display
| Setting | What it does |
|---|---|
| Show the result | On by default. Turn it off to show no row for this formula on the page. The formula still works, and a charged result is still charged. |
| Prefix | Text shown before a Show only result, such as Approx. |
| Suffix | Text shown after a Show only result, such as m², kg or days. |
| Decimal Places | How many decimal places a Show only result shows, from 0 to 10. The default is 2. |
A charged result always shows as money in your store’s currency, so Prefix, Suffix and Decimal Places only change Show only results.
7. What the customer sees
A Formula is a row in its group, titled with the layer’s name:
- Add to the price: the name and the price, such as “Glass $81.00”. The price changes as the customer changes the layers the formula reads. A price of 0 isn’t shown.
- Show only: the name and the result, with its prefix and suffix, such as “Opening area 1.80 m²”.
The row can’t be clicked or changed. With Show the result off, there’s no row at all.

8. In the summary, the cart and emails
| Where | Add to the price | Show only |
|---|---|---|
| Summary popup | Listed with its price | Listed with “Result: 1.80 m²”. With Show the result off, listed by name only. |
| Cart, checkout, orders, emails, the PDF and the invoice | “Glass ($81.00)” | “Opening area (1.80 m²)”, even with Show the result off |
When the customer adds to cart or asks for a quote, your store works every formula out again from their choices. What they pay is always the configurator’s figure, and editing the page can’t change it. A charged formula is always charged and listed, whatever the page sent.
9. Formulas that read other formulas
A variable can read another Formula. Its Value is that formula’s result.
Splitting a sum in two makes it easier to read, and lets the customer see the middle step. For example:
- Opening area, set to Show only, with Suffix
m²and 2 Decimal Places:
{width} * {height} / 1000000
- Variables:
{width}and{height}read the Width and Height Ranges’ Values, in millimetres.
- Glass, set to Add to the price:
{area} * 45
- Variables:
{area}reads the Opening area formula’s Value.
Gives: at 1200 × 1500 mm, “Opening area 1.80 m²” and “Glass $81.00”. Change the width, and both update.
Note: Don’t let formulas read each other in a loop, where A reads B and B reads A. Every formula in the loop gives 0. A Formula that reads the Price of the group it sits in is a loop too.
10. Conditions with if()
if() gives one result when something is true and another when it isn’t. Use it for price bands, volume pricing, surcharges and minimum charges.
if(test, result when true, result when false)
Always give all three parts. Unless an example says otherwise, set Result to Add to the price.
Two price bands
Handling costs 20 up to 1000 mm wide, and 35 above that.
if({width} <= 1000, 20, 35)
- Variables:
{width}reads the Width Range’s Value. - Gives: 20 at 900 mm, and 35 at 2400 mm.
Three or more bands
Put another if() in the “false” part. Each one adds a band.
if({width} <= 1000, 20, if({width} <= 2000, 35, 50))
- Gives: 20 up to 1000 mm, 35 up to 2000 mm, and 50 above that. So 1500 mm gives 35, and 2400 mm gives 50.
Tip: A Range can price itself in bands without a formula. See Price Tiers in the Range Layer page.
Volume pricing
Each unit costs 10, or 8 once the customer orders 10 or more.
if({qty} >= 10, {qty} * 8, {qty} * 10)
- Variables:
{qty}reads the Quantity Range’s Value. - Gives: 90 for 9 units, and 96 for 12 units.
Both conditions, or either
An oversize surcharge applies only when the opening is wider than 2400 mm and taller than 1800 mm:
if({width} > 2400 and {height} > 1800, 60, 0)
- Gives: 60 at 2500 × 2100 mm, and 0 at 2500 × 1700 mm.
It can also apply to any opening of 8 m² or more. Use brackets when you mix and and or:
if(({width} > 2400 and {height} > 1800) or {area} >= 8, 60, 0)
- Variables:
{area}reads the Opening area formula - Gives: 60 at 4800 × 1700 mm, which is 8.16 m².
Depending on a choice
Give the Glass select’s choices the Values 1 (Single), 2 (Double) and 3 (Triple). Triple glazing then adds 20 per m²:
if({glass} = 3, {area} * 20, 0)
- Variables:
{glass}reads the Glass select’s Value.{area}reads the Opening area formula. - Gives: 36 for triple glazing on 1.8 m², and 0 for the other choices.
The Values must be the numbers 1, 2 and 3, not the labels. Glass must be a Select or Radio field, not a group of options.
What a group costs
A group’s Price is what its chosen items cost together, including the items in its sub groups. Here fitting is free when the hardware comes to more than 100:
if({hardware} > 100, 0, 15)
- Variables:
{hardware}reads the Hardware group’s Price. - Gives: 0 when the hardware costs 120.50, and 15 when it costs 80.
Put this Formula in another group, such as Fitting. Inside Hardware it would read its own price and give 0.
When something isn’t chosen
Standard delivery costs 10, unless the customer picks the Express delivery option:
if(not({express}), 10, 0)
- Variables:
{express}reads the Express delivery option’s Value. - Gives: 10 without Express, and 0 with it.
A comparison on its own
A comparison gives 1 or 0, so it can switch a charge on by itself. This adds 5 once the customer orders 10 or more:
({qty} >= 10) * 5
Shown, not charged
A lead time, shown and not charged. Set Result to Show only, Suffix to days and Decimal Places to 0:
if({width} > 2400, 14, 7)
- Gives: “14 days” at 3010 mm, and “7 days” at 2000 mm.
11. More examples
Each example assumes Width and Height Ranges in millimetres.
| What it does | Expression | Variables | Gives |
|---|---|---|---|
| 45 per square metre | {width} * {height} / 1000000 * 45 | Width and Height Ranges’ Values | 81.00 at 1200 × 1500 mm |
| Trim around the edge, at 3.50 a metre, only when the Edge trim option is chosen | {trim} * 2 * ({width} + {height}) / 1000 * 3.5 | {trim} is the Edge trim option’s Value | 18.90 when chosen, 0 when not |
| One pane per 1.2 m², rounded up | ceil({width} * {height} / 1200000) | Width and Height | 2 at 1200 × 1500 mm |
| Fitting at 25 a pane | ceil({width} * {height} / 1200000) * 25 | Width and Height | 50 at 1200 × 1500 mm |
| 15% of the frame’s price | {frame} * 0.15 | {frame} is the Frame group’s Price, read from outside that group | 36 when the frame costs 240 |
| 45 per m², but never less than 60 | max({width} * {height} / 1000000 * 45, 60) | Width and Height | 60 at 1000 × 1000 mm |
| The first 10 free, then 2 each | max(0, {qty} - 10) * 2 | {qty} is the Quantity Range’s Value | 10 for 15 units |
| 12 per started metre | ceil({length} / 1000) * 12 | {length} is the Length Range’s Value | 36 at 2350 mm |
12. Use a Formula in Conditional Logic
With the Conditional Logic module on, a rule can test a formula:
- Formula result compares the formula’s result, using
=,≠,>,<,≥or≤. - Layer price compares what a charged formula costs.
Example:
IF
Size › Opening area ≥ 4.5
THEN
Disable Backrest Frame
A formula can also be the target of a rule: Show, Hide, Enable or Disable it. A formula is always selected, so Select and Deselect do nothing to it, and the editor warns you if you try.
Note: Hiding a charged formula doesn’t stop the charge. To charge only in some cases, use
if()in the expression.

13. Good to know
- A formula is always on. The customer can’t switch it off. To make a charge optional, multiply it by an option or a switch, which reads 0 until it’s chosen, or use
if(). =must match exactly. A computer can’t hold some decimals exactly, so0.1 + 0.2 = 0.3is false. Round first:round({price}, 2) = 49.99.- Work in whole units before rounding up or down. For the same reason,
ceil({area} / 1.2)gives 8 for an area of 8.4, where you’d expect 7. Working from millimetres avoids it:ceil({width} * {height} / 1200000)gives 7 at 4000 × 2100 mm. - A formula can’t give a discount. A charged result below 0 is charged as 0. A Show only result can be negative.
- Your formulas travel with the page, like every layer’s settings, so a customer can read them in the page source. Don’t put anything private in them.
- Duplicating. A copy of a formula reads the same layers as the original. After duplicating a group, save the configurator and reload the editor before you change the copy, so the copy’s settings are saved as its own. Then point the copy’s variables at the copied layers.
- Turning off the Formula module stops every formula from showing and charging. Turn it back on before you save a configurator that has formulas: saving while it’s off can damage expressions that use
<or>, or a%directly followed by a number. - Formula is a Pro feature. The Lite version doesn’t include it.
14. Messages in the editor
| Message | What to do |
|---|---|
| Valid | Nothing. The formula is ready. |
| No variable is called “width”. | Add a variable with that name under Variables, or fix the spelling. |
| “width” is never used in the expression. | Use the variable in the expression, or remove it. |
| “width” is named twice. | Give one of the two variables another name. |
| “width” does not point at a layer. | Choose a Layer for the variable. |
| “width” points at a layer that no longer exists. | Choose another layer, or remove the variable. |
| A formula cannot read itself. | Choose a different layer for the variable. |
| “my-width” is not a usable name — use letters, digits and underscores. | Rename it, for example to my_width. |
| There is no function called “IF”. | Write functions in lowercase: if. The same goes for and, or and not. |
| “if” takes 3 argument(s), not 2. | Add the missing part, such as the result for when the test is false. |
| Comparisons cannot be chained; join them with “and”. | Write {w} > 100 and {w} < 200. |
| A bracket is never closed. | Add the missing ). |
| A variable is missing its closing brace. | Add the missing }. |
| ” width ” is not a valid variable name. | Remove the spaces inside the braces. |
| “.” cannot be used here. | Put a digit before the point: 0.5. The same message names any other character the expression can’t use. |
| Unexpected “,”. | A comma only separates a function’s parts. Remove thousands separators from numbers. |
| The expression ends too early. | Finish the sum: something is missing after the last operator. |
| Longer than the 500 character limit. | Shorten it, or split it into two formulas. |
| Nested too deeply — the limit is 10. | Use fewer brackets and functions inside each other, or split it into two formulas. |
15. Troubleshooting
| What you see | Why, and what to do |
|---|---|
| There’s no Formula icon in the editor. | Turn on the Formula module. Formula needs the Pro version. |
| The result is 0. | Check that the editor says Valid. A variable reads 0 when its layer isn’t chosen, dividing by 0 gives 0, and formulas in a loop give 0. |
| A select’s choice reads 0. | Give the choices numbers as their Values, and check the editor hasn’t copied the Label into an empty Value. Use a Select or Radio field, not a group of options. |
| A formula reading a group’s Price always gives 0. | The formula sits inside that group, so it reads itself. Move it to another group. |
| The price doesn’t show on the page. | The result is 0, the formula is set to Show only, or Show the result is off. |
| The total is a cent off what you worked out. | A charged result is rounded to your store’s decimal places, halves up. Round inside the formula if you need another rule: ceil({x} * 100) / 100 always rounds up to the cent. |
| Hiding the formula with Conditional Logic doesn’t remove its charge. | Hidden layers still count. Use if() in the expression instead. |