Order rules
How the Rules Engine integration with Commerce Layer Core API promotions resource works behind the scenes
Last updated
How the Rules Engine integration with Commerce Layer Core API promotions resource works behind the scenes
Last updated
When you create a flex promotion filling up the related rules
object you're basically setting up order rules, meaning that the Core API integration will check your rules against the payload of an order. For performance reasons, it is a lightweight version of the , containing only the attributes and relationships needed to evaluate the rule conditions and apply the related actions based on the values specified in the rule keys (e.g. fields, selectors, etc.).
The resulting promotion (i.e. the rule actions) will be applied to all the orders that satisfy the rule conditions.
The structure, constraints, and data types for the order rules JSON dataset are described in the public Order Rules JSON schema. Feel free to use it to implement validation scripts for your rules, automatically generate code, or just better understand how the Rules Engine works behind the scenes.
The following order rule offers free shipping and a 10% discount on the line items associated with an SKU if the email of the customer belongs to a specified domain: