Price rules
How the Rules Engine integration with Commerce Layer Core API price lists resource works behind the scenes
Last updated
How the Rules Engine integration with Commerce Layer Core API price lists resource works behind the scenes
Last updated
When you create or patch a price list filling up the related rules
object you're basically setting up price rules, meaning that the Core API integration will check your rules against the payload of a price. 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.).
Adding a price rule to a price list will result in applying the discounts due to the rule actions to all the price list's prices that satisfy the rule conditions.
The structure, constraints, and data types for the price rules JSON dataset are described in the public Price 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 rule offers a 20% discount on the prices of some promotional products (identified by a prefix in their SKU code) for the price lists associated with specific markets: