Functions are tools that help you access dynamic data, such as checking if tomorrow is a workday or finding the next holiday for the sender. They are used when writing advanced conditions. This guide explains how functions work and how to use them.
Content in this article:
- What is a function?
- Function input and data
- List of available functions
- Inspecting functions
- Special functions
- Rounding functions
-
Join functions
What is a function?
A function is a reusable tool that returns data based on certain inputs. For example, a function can tell you:
- The next public holiday
- Whether a specific date is a workday
- A number, date, or text string based on your input
If you do not provide any input (called an argument), the function will use a default, usually based on today’s date and the relevant time zone.
Function inputs and data
Some functions accept one or more arguments (inputs). These inputs must follow two rules:
- Correct type: A function expecting a date will not accept a number or text.
- Correct order: If a function expects a string first and a number second, you must follow that order.
You can sometimes leave out later arguments, but you must always include the earlier ones.
Valid: FunctionB(String, Integer)
Invalid: FunctionB(String, Date)
Functions return different types of data:
- Text (e.g., a holiday name)
- Numbers (e.g., number of days until a date)
- Dates (e.g., the next workday)
You can use this data in further conditions, like adding days to a date or comparing values.
List of available functions
|
Name |
Result type |
Argument types |
Mandatory arguments |
Only available for expressions ? |
|
todayIsWeekendSender/todayIsWeekendReceiver |
Boolean |
- |
- |
- |
|
todayIsHolidaySender/todayIsHolidayReceiver |
Boolean |
- |
- |
- |
|
dateNowSender/dateNowReceiver |
Date |
Date |
- |
- |
|
nextHolidayDateSender/nextHolidayDateReceiver |
Date |
Date |
- |
- |
|
nextWorkDateSender/nextWorkDateReceiver |
Date |
Date |
- |
- |
|
nearestWorkDateSender/nearestWorkDateReceiver |
Date |
Date |
- |
- |
|
carrierEtaFromDate |
Date |
- |
- |
Yes |
|
carrierEtaToDate or carrierEtaDate |
Date |
- |
- |
Yes |
|
dateTimeNowSender/dateTimeNowReceiver |
DateTime |
- |
- |
- |
|
carrierEtaFromDateTime |
DateTime |
- |
- |
Yes |
|
carrierEtaToDateTime or carrierEtaDateTime |
DateTime |
- |
- |
Yes |
|
timeNowSender/timeNowReceiver |
Time |
- |
- |
- |
|
todayAsNumberInYearSender/todayAsNumberInYearReceiver |
Integer |
- |
- |
- |
|
weekdayNumberSender/weekdayNumberReceiver |
Integer |
- |
- |
- |
|
weekday |
Integer |
DateTime |
- |
- |
|
maximumPackageWeightKg |
Double |
- |
- |
- |
|
minimumPackageWeightKg |
Double |
- |
- |
- |
|
totalPackageWeightKg |
Double |
- |
- |
- |
|
maximumPackageVolumeCm3 |
Double |
- |
- |
- |
|
minimumPackageVolumeCm3 |
Double |
- |
- |
- |
|
totalPackageVolumeCm3 |
Double |
- |
- |
- |
|
maximumPackageLengthCm |
Double |
- |
- |
- |
|
minimumPackageLengthCm |
Double |
- |
- |
- |
|
totalPackageLengthCm |
Double |
|
|
|
|
maximumPackageWidthCm |
Double |
- |
- |
- |
|
minimumPackageWidthCm |
Double |
- |
- |
- |
|
totalPackageWidthCm |
Double |
|
|
|
|
maximumPackageHeightCm |
Double |
- |
- |
- |
|
minimumPackageHeightCm |
Double |
- |
- |
- |
|
totalPackageHeightCm |
Double |
|
|
|
|
maximumPackageCircumferenceCm |
Double |
|
|
|
|
minimumPackageCircumferenceCm |
Double |
|
|
|
|
maximumPackageLengthCircumferenceCm |
Double |
|
|
|
|
minimumPackageLengthCircumferenceCm |
Double |
|
|
|
|
monthNowSender/monthNowReceiver |
String |
- |
- |
- |
|
dayNowSender/dayNowReceiver |
String |
- |
- |
- |
|
nextWorkDaySender/nextWorkDayReceiver |
String |
Date |
- |
- |
|
nearestWorkDaySender/nearestWorkDayReceiver |
String |
Date |
- |
- |
|
carrierEtaFromDay |
String |
- |
- |
Yes |
|
carrierEtaToDay or carrierEtaDay |
String |
- |
- |
Yes |
|
carrierEtaInterval |
String |
- |
- |
Yes |
|
toUpperCase |
String |
String |
- |
- |
|
allPackageContents |
Array |
- |
- |
- |
Inspecting functions
Conditions are evaluated in two phases:
- Phase 1: Basic checks (no inspecting functions)
- Phase 2: Advanced checks using inspecting functions
Inspecting functions look at more detailed or external data (like holidays) and are marked with the label "INSPECTING". If no inspecting functions are used, phase 2 will be empty.
Inspecting functions do not have a normal return type. Instead, they affect the Checkout delivery options in a more general way, for example, by reordering the options returned.
| Name | Result |
| enabled | Boolean |
| costPrice | Double |
| salesPrice | Double |
Special functions
The following "unit functions" are also available to use in combination with certain operations (none of them support any arguments):
| Name | Result type |
| hour | TimePeriod |
| minute | TimePeriod |
| year | Period |
| month | Period |
| day | Period |
| workdaySender/workdayReceiver | WorkdayPeriod |
Workdays can vary depending on location. What is a workday for the sender might be a holiday for the receiver. That is why the workday unit must be used with either Sender or Receiver.
When adding workdays to a date, weekends and national holidays are considered based on the relevant time zone.
Note: You can only add or subtract up to 60 workdays. Anything beyond that (e.g., 61) will be treated as 60. This limit helps maintain system stability and can only be increased with caution.
We also offer constant functions, which represent commonly used values in conditions. They simplify expressions, like checking if a date falls on a weekday, e.g., ”weekday(dateNowSender) between monday;friday”.
| Name | Result type |
| monday | Integer |
| tuesday | Integer |
| wednesday | Integer |
| thursday | Integer |
| friday | Integer |
| saturday | Integer |
| sunday | Integer |
Rounding functions
The Rounding functions can be used to round a value (e.g., the price). The value can be either numerical or a function such as costprice/salesprice:
round(123.45) → round up integer
round(123.45; 10.0) → round up to 10
round(123.45; 10.0; “down”) → round down to 10
round(123.45; 10.0; “down99”) → round down to 10 and subtract the smallest amount based on fraction digits to get 119.99
Join functions
The join() function allows you to combine multiple string values into one single string. This could be especially useful when you want to dynamically build lookup keys based on several data points and use these keys to fetch values from a Condition List.
Typical use cases could include:
- Constructing composite keys for lookups (e.g., Zone + Currency)
- Simplifying complex rule logic
- Dynamically selecting values such as free-shipping thresholds or price tiers based on zone, weight, volume, or currency
By combining values at runtime, join() can replace long conditional expressions with shorter rule logic.
Function Syntax
join("/"; ["hello";"world"]) => "hello/world"
join("+"; ["hello"; 1; 2; 3]) => "hello+1+2+3"
Example:
cart_price >= toNumber(join(""; [tocountry from "Zones"; currency]) from "FreeShipThresholds")
In the expression above, the country is translated into a zone using the lookup tocountry from a condition list called "Zones", which is expected to return a string such as "Zone1". Using join, the zone is then combined with the currency, producing, for example, "Zone1EUR". That value is then used to look up the threshold in a condition list called "FreeShipThresholds".
The output is a single concatenated string.