Overview
A formula consists of:
- Functions
- Attribute reference codes
- Constants
- Mathematical operators
Example:
Round((Width * Height) / 1000000) * [Price.BaseValue]
This formula:
- Multiplies the Width and Height values.
- Converts the result to square metres.
- Rounds the calculated value.
- Multiplies the result by the base price.
Attributes can be used in formulas only when they have a Reference Code (refCode) defined.
The formula engine uses the reference code to retrieve the attribute value during the calculation.
Width: Attribute Reference Code used to retrieve the width value of the product.
Height: Attribute Reference Code used to retrieve the height value of the product.
These reference codes can be used directly in formulas to retrieve the corresponding attribute values during calculations.
Important: Attribute reference codes are case-sensitive and must match the defined reference code exactly.
Price.BaseValue
[Price.BaseValue] returns the unit price defined in the Price Value section.
Syntax:
[Price.BaseValue]
Example:
Width * [Price.BaseValue]
The value is a system constant and always uses the same syntax:
[Price.BaseValue]
Round
Rounds a calculated value to a whole number (0 decimal places).
Syntax
Round(value, 0)
Parameters
| Parameter | Description |
|---|---|
| value | Numeric value or calculation to round. |
| decimal | Decimal places needed. |
Examples
Suppose height is 34.5 in², depth is 24 in², and we are trying to find the area in ft² with the result rounded up to 1 decimal place:
Result:
Rounds the result of the calculation before it is used in subsequent pricing calculations.
For results in 2 decimal places:
Results:
QuantityPerPack
Some products — such as worktops, panels, and other surface or linear materials — are priced individually but need to be displayed using a calculated measurement (e.g., area or length) instead of a plain item count. QuantityPerPack lets you define that displayed quantity separately from the pricing calculation.
Syntax
QuantityPerPack(formula, 'UOM')
Parameters
| Parameter | Description |
|---|---|
formula | The calculation used to compute the quantity to display (e.g. Width * Depth / 1000000). |
UOM | The unit of measure the calculated quantity should be displayed in (e.g. M² for square metres, M for linear metres). |
Notes
- The function supports decimal quantities.
- The displayed quantity is calculated using the provided formula.
- Ensure units used in the formula are consistent with the specified unit of measure.
Calculate area and multiply by price
(Width * Height / 1000000) * [Price.BaseValue]
This formula:
- Calculates the area
- Converts square millimetres to square metres
- Multiplies the result by the unit price
Calculate area and round the value
Round((Width * Height) / 1000000, 2) * [Price.BaseValue]
This formula:
- Calculates the area
- Rounds the result to 2 decimal places
- Multiplies the rounded value by the unit price
Calculate area and display as quantity
QuantityPerPack(Width * Depth / 144, 'f²')
This formula:
- Calculates the area from Width and Depth
- Converts square millimetres to square feet
- Displays the result as the quantity (e.g. 2.35 f²) instead of the item count