Custom promotion rules

The custom promotion rule object and the allowed CRUD operations on the related resource endpoint

Commerce Layer provides a promotional engine built on top of two main resources: promotions and promotion rules.

Custom promotions rules add extreme flexibility when building your promotion logic. They are used to trigger the associated promotion only when some specific conditions on the order attributes and/or relationships are met (e.g. the customer is tagged with a specific tag, the SKU code of the products in the cart contains a specific sequence of character, etc.). Those conditions are defined using the filters attribute:

  "filters": {
    "{{predicate}}": {{value}},

To compose the filter predicate you just need to follow the same syntax you use when filtering a collection of resources — {{attributes}}_{{matcher}}. You must specify filtering rules as a valid JSON object. List values for the *_in matcher need to be expressed as arrays.

Since if you try to filter a collection of resources by a non-filterable or wrong/mispelled field you don't get any error and the API returns the full unfiltered list, make sure to use filters correctly (you can test them before via API). Otherwise, it would be like using no promotion rule and the promotion would be applied to all the orders in scope. The same happens if you create a custom promotion rule with no filters attribute.

Last updated