Scope

How to change a condition's scope

A condition is checked against a specific payload to determine whether it's a match or not. The payload can contain several instances of the resources specified in the condition's field. By default a condition is considered satisfied if at least one (i.e. any) of those instances matches the condition's requirements. If you want to override this behavior and ensure that a condition is satisfied only if all of those instances match the condition's requirements, you need to modify the condition scope.

Example

Let's consider the previous example and add the scope key with value all to the second condition to better understand how the matching criteria change:

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 the string TSHIRT:

"conditions": [
  {
    "field": "order.tags.name",
    "matcher": "eq",
    "value": "dropship"
  },
  {
    "field": "order.line_items.sku.code",
    "matcher": "start_with",
    "value": "TSHIRT",
    "group": "tshirts"
  }
]

Last updated