Introduction
Conditions are important for setting up rules and actions in the Rule engine. The advanced mode in the Rule engine allows you to use more complex conditions. They use operators, variables, constants, and functions to help determine checkout options based on factors like weight, cart price, and destination.
Rules consist of one or more conditions connected to actions, which can influence fields, addons, or delivery options, determining the outcomes when the conditions are satisfied. The Rule engine interface makes it easy to set up conditions and actions.
For more information on common use cases, take a look at our article Using the Rule engine, which offers a step-by-step guide to creating basic conditions.
This article will focus on the more advanced aspects of conditions:
- Advanced view in the Rule engine
- List of valid operators
-
Custom parameters
- Boolean
- Text
- Condition lists - Expressions
Advanced view in the Rule engine
In the Rule engine, you have the option to switch to Advanced mode. This contains a single text field and enables you to write conditions manually for better control.
Please note that any built-in or custom parameters you want to use in the conditions must be enabled under Parameters. Read more here: Enable parameters
Examples:
vip = trueCustom text "vip" equals true
cart_price < 100Cart price is less than 100
to_country != "SE"Country is not equal to Sweden
to_postal_code < "10000" and to_country = "SE" and to_postal_code > "20000"Receiver post code is less than 10000 and receiver country is equal to Sweden, and post code is less than 20000
cart_price >= 5000 or weight_kg >= 20Cart price is greater than or equal to 5000, or weight is greater than or equal to 20
weight_kg >= 1.9 or volume_cm3 >= 8000Weight is greater than 1.9 kg, or volume in cubic centimeters is greater than or equal to 8000
date > "2025-12-31"Date is after December 31, 2025
cart_price > 600 and currency = "SEK" and VIP = trueCart price is greater than 600 and currency is SEK and custom parameter VIP is true.
List of valid operators
Writing conditions require the use of operators:
| Operator |
Explanation |
|---|---|
| = | Is equal to |
| != | Is not equal to |
| > | Is greater than |
| >= | Is greater than or equal to |
| < | Is less than |
| <= | Is less than or equal to |
| | or OR | Or |
| & or AND | And |
| ! or NOT | Not |
| in | Contains |
Custom parameters
Here are some examples of how to use custom parameters in advanced mode. Custom parameters must be enabled under Parameters to be available in advanced mode. See Enable parameters.
Boolean
Custom parameters can be set to true or false, like these examples:
bulky = true
b2b = true
VIP = false
Text
You can specify a text that must be present for a custom parameter. Examples:
freightclass = "A"
member = “gold”
type = “nailpolish”
Condition lists
You can specify a parameter in a condition list by following the format parametername in "conditionlistname". Example:
to_postal_code in "zipcodes_zone1"
For more information about condition lists, please see this article: Getting started with Condition lists. It includes a section on using condition lists in the rule engine.
Expressions
Expressions work similarly to Conditions but serve a different purpose. While Conditions return a boolean (true/false) to decide if an action should happen, Expressions are used to dynamically set values in fields like prices or messages. Expressions must be written inside curly braces, "{}".
For example, in a price field, an expression might use a custom variable from the request. Or, to show a delivery message, you could write:
"Will be delivered on {nextWorkingDayReceiver()}"
Here, {nextWorkingDayReceiver()} is the expression. The curly braces {} tell the system to evaluate the content inside. If the function returns "Monday", the final message becomes:
"Will be delivered on Monday"
Note: If an expression returns a boolean (like a condition), it will display "true" or "false" as text, which may not be what you want.
Some functions are only available in expressions, not in conditions, because they depend on knowing which shipping option is being used, something not available at the checkout level.
| Name | Result type |
|---|---|
| carrierEtaFromDate | Date |
| carrierEtaToDate or carrierEtaDate | Date |
| carrierEtaFromDateTime | DateTime |
| carrierEtaToDateTime or carrierEtaDateTime | DateTime |
| carrierEtaFromDay | String |
| carrierEtaToDay or carrierEtaDay | String |
| carrierEtaInterval | String |
| Operator |
Explanation |
|---|---|
| + | Addition |
| - | Subtraction |
| * | Multiplication |
| / | Division |
| % | Modulo |