WordPress / Alovio Calculator
Formulas
Write formulas in Alovio Calculator — reference fields, use operators and functions, and trust the decimal-safe math.
A formula field computes a value from the visitor’s other answers — a per-unit total, a discount, a subtotal, or the grand total itself. Formulas are validated live as you type.
Referencing fields
Reference another field by its name in curly braces, e.g. {area} or {rate}. A reference returns
that field’s current value:
- Number, slider and quantity fields return their entered number.
- A choice field (dropdown, radio, checkboxes) returns the price of the selected option(s), or 0 if nothing is selected.
- A toggle returns its price when on, 0 when off.
- Another formula returns its computed result, so you can build a formula on top of a formula.
Operators
The usual arithmetic, left to right with standard precedence:
{area} * {rate} + {callout}
( {width} * {height} ) / 1000
Supported: + − * (or ×) / (or ÷), with parentheses for grouping.
Functions
| Function | Does |
|---|---|
if(test, a, b) | Returns a when the test is true, otherwise b |
min(a, b, …) | The smallest of its arguments |
max(a, b, …) | The largest of its arguments |
round(value, decimals) | Rounds to decimals places (decimals optional) |
ceil(value) | Rounds up to a whole number |
floor(value) | Rounds down to a whole number |
abs(value) | The absolute (positive) value |
Examples
# £45 per m², minimum charge £120
max( {area} * 45, 120 )
# 10% express surcharge when the express toggle is on
{subtotal} + if( {express}, {subtotal} * 0.10, 0 )
# round the final total to whole pounds
round( {subtotal} - {discount}, 0 )
Decimal-safe math
Calculations use exact fixed-point decimal arithmetic, not floating point — so 0.1 + 0.2 is exactly
0.3 and totals never drift by a cent. The same engine runs in the browser preview and on the
server, verified against a shared test suite on every release, and the server independently
recomputes every submitted quote. The number a visitor sees is the number you receive.
Tips
- Keep one formula field as your total and reference smaller formulas into it — easier to read and to debug.
- A formula can reference the same fields your conditional logic uses, so a hidden field (which counts as empty) drops cleanly out of the math.
- Circular references are caught for you — a formula can’t depend on itself.