For certain types of product options (available under the Settings page) it may be required to enter an expression formula which is then used during order processing to perform a calculation for some aspect of the product being manufactured. For example, if your organization manufactures curtains then the curtain header options require that expressions be defined for calculating curtain hook counts and fabric widths.
Omnivisor provides support for dynamic expression formulas via its inclusion of the Expr expression language. This language supports standard arithmetic operators and support for variables which makes it possible to write comprehensive formulas for the numeric calculation of product measurements and other product-related details.
While the link in the previous paragraph may be a useful resource for detailed and complete documentation of the Expr language, this page will cover the basics necessary for the authoring of expression formulas in Omnivisor.
Literal Values #
To include literal numeric values in your formula, simply type either the integer (whole number) or float (number with decimals) into the expression. For example, an expression with the following single literal value when calculated will simply return a value of 42:
42
Operators #
The following arithmetic operators may be used in expressions to perform mathematical operations.
Operator | Description | Example |
+ | Adds two values together | 8 + 7 (result equals 15) |
– | Subtracts one value from another | 20 – 3 (result equals 17) |
* | Multiplies two values together | 4 * 3 (result equals 12) |
/ | Divides one value by another value | 21 / 3 (result equals 7) |
Number Functions #
The following number functions may be used to perform a variety of mathematical operations.
Function | Description | Example |
max(n1, n2) | Returns the maximum of the two numbers n1 and n2 | max(5, 7) Result equals 7 |
min(n1, n2) | Returns the minimum of the two numbers n1 and n2 | min(5, 7) Result equals 5 |
abs(n) | Returns the absolute value of a number | abs(-5) Result equals 5 |
ceil(n) | Returns the lowest integer value greater than or equal to n | ceil(1.5) Result equals 2.0 |
floor(n) | Returns the greatest integer value less than or equal to n | floor(1.5) Result equals 1.0 |
round(n) | Returns the nearest integer, rounding up if the decimal part of the value is exactly 0.5 | round(1.5) Result equals 2.0 |
Variables #
Depending on what type of product option the expression formula is defined, certain variables may be available for use within the calculation. Refer to each of those sections for details on the available variables and for examples of how they should be used.
Curtain Header Options – Fabric Width Formula