Formula functions
You can use these functions in the price formula, conditions, field formulas and interval formulas. Function names are in capitals.
Operators
OR
| is true when at least one side is true.
js
[width] > 10 | [height] > 10AND
& is true when both sides are true.
js
[width] > 10 & [height] > 10See all operators in Formulas.
Math
SQR
Square of a number.
js
SQR(5) → 25SQRT
Square root.
js
SQRT(25) → 5POW
Power.
js
POW(2, 3) → 8ABS
Absolute value.
js
ABS(-10) → 10SIGN
Sign of a number: 1, -1 or 0.
js
SIGN(-10) → -1MIN
Smallest value. Takes any number of values.
js
MIN(3, 1, 2) → 1MAX
Largest value. Takes any number of values.
js
MAX(3, 1, 2) → 3SUM
Sum of the values.
js
SUM(1, 2, 3) → 6EXP, LN, LOG, LOGN
Exponential, natural log, log base 10, and log with a base.
js
EXP(0) → 1
LN(1) → 0
LOG(100) → 2
LOGN(2, 8) → 3SIN, COS, TAN, COTAN, ATAN, SINH, COSH
Trigonometry, with angles in radians. PI is 3.14159…
js
SIN(PI / 2) → 1RND
Random number from 0 to 1.
js
RND()Rounding
CEIL
Rounds up to a whole number.
js
CEIL(3.2) → 4
CEIL(-3.14) → -3FLOOR
Rounds down to a whole number.
js
FLOOR(3.8) → 3
FLOOR(-3.2) → -4TRUNC
Removes the decimals.
js
TRUNC(4.9) → 4
TRUNC(-3.5) → -3ROUND
Rounds to a number of decimals. The second value is required.
js
ROUND(3.14159, 2) → 3.14
ROUND(2.5, 0) → 3ROUNDUP
Rounds up to a number of decimals.
js
ROUNDUP(3.141, 2) → 3.15ROUNDDOWN
Rounds down to a number of decimals.
js
ROUNDDOWN(3.149, 2) → 3.14Logic
IF
IF(condition, value if true, value if false). True means any value other than 0.
js
IF([width] > 100, 20, 10)Text
Write text fields in double quotes: "[engraving]".
STRLEN
Number of characters.
js
STRLEN("hello") → 5CHECK
1 if the text is not empty, 0 if it is empty.
js
CHECK("[engraving]") * 5CONTAINS
1 if the first text contains the second, else 0.
js
CONTAINS("hello", "ell") → 1SUBSTR
Part of a text: SUBSTR(text, start, length). The first character is at 0.
js
SUBSTR("hello", 1, 3) → "ell"REPLACE
Replaces every match.
js
REPLACE("hello", "l", "L") → "heLLo"CONCAT
Joins texts.
js
CONCAT("a", "b", "c") → "abc"TRIM, LTRIM, RTRIM
Removes spaces at both ends, at the start, or at the end.
js
TRIM(" a ") → "a"VAL, NUM
Turns a text into a number. VAL gives 0 for a text that is not a number; NUM gives an error.
js
VAL("12.5") → 12.5
NUM("12") → 12CHR
Character from its code.
js
CHR(65) → "A"Binary
BINARY_AND
js
BINARY_AND(5, 3) → 1BINARY_OR
js
BINARY_OR(5, 3) → 7Not available
These functions of the PrestaShop module are not available in the app: GRID, LABEL, REF, NUM_SELECTED, PRICE, MOD and STR. Use the Grids tab instead of GRID, and % instead of MOD.
TIP
The price formula must give a number. Text functions are useful inside a number formula, for example STRLEN("[engraving]") * 0.5.
