Formula functions reference

Introduction

Pricing formulas can contain functions to make your product’s pricing even more powerful. Function parameters can be simple data (such as a number or text), or can contain dynamic code and variables like [field.xxx] to reference dynamic data.

All functions

Available in all versions of the plugin

FunctionDescriptionExample
min(a; [b; c; ...])Returns the smallest of the given numbers.min(100; [field.600d34143bd65])
max(a; [b; c; ...])Returns the largest of the given numbers.max(100; [field.600d34143bd65])
len(string)Returns the length of a string.len(“a quick brown fox”)

Available in the Extended version

FunctionDescriptionExample
if(logical; value1; value2)Returns value1 if the logical argument is true, otherwise it returns value2. Can also be used to make nested IF statements.if([field.600d34143bd65] > 50; 10; 20)
or(logical1; [logical2; ...])Returns true if any one of the arguments is true.or([field.600d34143bd65];[field.799e14133be99])
and(logical1; [logical2; ...])Returns true if all the arguments are true, returns false otherwise.and([field.600d34143bd65];[field.799e14133be99])
datediff(date1; date2)Returns the difference (in days) between two dates.datediff([field.600d34143bd65];[field.799e14133be99])
today()Returns today’s date. Can be used in the datediff function for further calculation.today()
checked(field ID)Returns how many items are selected in a multi-select field (such as checkboxes, image swatches, …).checked(600d34143bd65)
files(field ID)Returns the count of uploaded files for that field.files(600d34143bd65)
round(number)Round (up or down) the value to the nearest number.round(4.8) => 5
ceil(number)Round up to the nearest number.ceil(4.8) => 5
floorRound down to the nearest number.floor(4.8) => 4
abs(number)Returns the absolute value of a number.checked(-5) => 5
pow(base; exponent)function returns the base to the exponent power, as in baseexponent.pow(4;2) => 4² => 16
sqrt(number)Returns the square root of a number.sqrt(144) => 12
sin(number)Returns the sine of a number.sin(5)
cos(number)Returns the cosine of the specified angle. The number parameter specifies radians.cos(5)
tan(number)Returns the tangent of a number.tan(5)

Nesting functions

Nesting functions inside other functions is possible too. For example, you could create a more complex IF-ELSE structure like this:

if( condition; true; if(condition2; true2; false2))

Troubleshooting formulas

Are you using functions but your formulas produce incorrect results? Check this article to troubleshoot your formulas.

Was this article helpful?

Related Articles