Conditions
How to set a rule's conditions and what are the required and optional parameters to set
For each rule you need to provide one or more conditions
as an array of condition objects.
Conditions determine when a rule's actions are triggered by defining the criteria that must be met for the rule to be applied. They can check for specific values, quantities, or any other attributes of the involved resources and their relationships.
Multiple conditions are evaluated according to an AND
logic (the rule matches if all the conditions are met). You can override this default behavior and force the rule to be evaluated according to an OR
logic (the rule matches if any of the conditions are met) by specifying the conditions_logic
attribute accordingly at the rule level.
For performance reasons, the maximum number of conditions within a rules payload is 50.
For each condition you must define at least the involved field and the matcher to be used to compare that field's value against the desired one (if any). Additional parameters can be also specified:
field
The resource's field on which to evaluate the condition (expressed in dot notation). Must be an attribute, cannot be a resource.
"order.line_items.tags.name"
matcher
"eq"
value
true
2000
"summer-sale"
[ "2018-01-01T00:00:00+02:00", "2018-03-31T23:59:00+02:00" ]
{ "in_or": [ "men", "women" ], "not_in_and": [ "sales", "vip" ] }
scope
"any"
group
"discountable-items"
aggregations
Additional requirements on the aggregated matches of the conditions.
nested
Additional conditions to be met by the matches of the parent condition.
Referring to the Core API integration, a condition field
must be an attribute — i.e. the last leaf of the relationship tree using the dot notation (e.g. it can be order.line_items.sku.code
but it cannot be order.line_items.skus
or just order
). Some virtual relationships related to the currently issued JWT token are also enabled.
Example
Assuming no conditions_logic
is specified at the rule level, the following couple of conditions check if an order is tagged as dropship
and contains at least a line item whose SKU code starts with TSHIRT
. The matching line items are grouped as tshirts
so that the related actions (that will be triggered only if both conditions are satisfied) can be applied only to the line items that matches the second condition:
Last updated