Need to create rules based on bundles?
Learn more
LogoLogo
APIsChangelog
  • Getting started
  • Rules
  • Conditions
    • Scope
    • Aggregations
    • Nested
    • Dynamic values
  • Actions
    • Types
      • Percentage
      • Fixed amount
      • Fixed price
      • Buy X pay Y
      • Every X discount Y
    • Bundle
      • Balanced
      • Every
    • Aggregation
    • Limit
  • Matchers
  • Operators
  • Check and validation
  • Core API integration
    • Order rules
    • Price rules
    • Virtual relationships
  • Resources
    • Promotions
    • Price lists
  • Use cases
    • Promotions
      • Discount line items based on item's price
      • Get a discount when paying by credit card
      • Discount an order based on promo item and total number of items
      • Offer a specific shipping method for free in a specific country
      • Discount items with large stock availability
      • Discount all the SKU in an order based on the shipping country
      • Discount all the SKU in an order based on the customer email domain
    • Price lists
      • Discount all prices greater than or equal to a specific value
      • Discount specific SKUs for new clients
      • Change strike-through price based on customer email domain
On this page

Conditions

How to set a rule's conditions and what are the required and optional parameters to set

PreviousRulesNextScope

Last updated 2 months ago

For each rule you need to provide one or more conditions as an array of condition objects.

Conditions determine when a rule's 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 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:

Key
Type
Required
Description
Example

field

String

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

String

"eq"

value

BooleanIntegerStringArrayObject

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

String

"any"

group

String

"discountable-items"

aggregations

Array

Additional requirements on the aggregated matches of the conditions.

nested

Object

Additional conditions to be met by the matches of the parent condition.

Referring to the , 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 related to the currently issued JWT token are also enabled.

Example

Assuming no conditions_logic is specified at the 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:

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

The matcher to be used against the field and value (check the ).

The value to be compared with the field value according to the matcher (required for , unavailable for ). are also allowed.

The policy to determine if the condition is a match. Can be one of any or all, default is all (more information ).

A label to identify the matches of the condition (if not specified a random UUID will be automatically generated and added by the ).

Learn more .

Learn more .

list of available matchers
here
here
here
actions
rule
virtual relationships
rule
Dynamic values
Core API integration
Core API integration
some matchers
some others