Arrays in rule configurations are useful for handling lists of items. Instead of creating separate rules for each item, you can group them into an array. This allows you to create rules that check for the presence of multiple products, categories, or other parameters efficiently. Arrays simplify rule creation when you need to work with groups of items, whether you need to check for all of them or just a single one.
Given the configuration of the products parameter
And the following rules:
["laptop";"headset"] all in products
-
Name: "Array - [all in] - Products Parameter"
-
Use Advanced Conditions: The conditions are defined in "Advanced" mode.
-
Condition: Check if the "products" parameter contains both items.
-
Syntax: ["laptop";"headset"] all in products
-
Action (when condition is true): Set the text in "Field 1" to "products contains both laptop and headset"
["laptop";"headset"] in products
-
Name: "Array - [one of] - Products Parameter"
-
Use Advanced Conditions: The conditions are defined in "Advanced" mode.
-
Condition: Check if "at least one of" the items in the array needs to be present in "products".
-
Syntax: ["laptop";"headset"] in products
-
Action (when condition is true): Set the text in "Field 2" to "products contain at least one of laptop or headset"
"laptop" in products
-
Name: "Array - [in] - Products Parameter"
-
Use Advanced Conditions: The conditions are defined in "Advanced" mode.
-
Condition: Check if "products" parameter contains the item "laptop".
-
Syntax: "laptop" in products
-
Action (when condition is true): Set the text in "Field 3" to "products contains Item laptop"
!(["headset"] in Products)
-
Name: "Array - ![in] - Products Parameter"
-
Use Advanced Conditions: The conditions are defined in "Advanced" mode.
-
Condition: Check if "products" parameter contains the item "laptop".
-
Syntax: !(["headset"] in Products)
-
Action (when condition is true): Set the text in "Field 4" to "products should not contain Item headset"
!(["laptop";"headset"] in products)
-
Name: "Array - ![all in] - Products Parameter"
-
Use Advanced Conditions: The conditions are defined in "Advanced" mode.
-
Condition: Check if "products" parameter do not contain the both items.
-
Syntax: !(["laptop";"headset"] in products)
-
Action (when condition is true): Set the text in "Field 5" to "products should not contain Items laptop and headset"
Expected output:
Empty Array
["laptop"]
["headset"]
["laptop", "headset"]