Percentage

How the percentage discount action works, what are the required and optional parameters to set it up, and the resources for which it's enabled

Actions of type percentage enable you to apply a percentage discount to the amount of a specific field.

When setting up a percentage discount action, in addition to the action type, you need to specify at least the attribute or resource on which to apply the action as the selector key value and fill the value key with the float number corresponding to the percentage discount to be applied (for more information on the parameters listed in the table below and how they work please refer to the main actions page):

Key
Type
Required
Notes

type

String

Must be "percentage".

selector

String

identifier

String

Can be set only if the selector key value is an attribute.

groups

Array

Required when using bundles.

bundle

Object

aggregation

Object

apply_on

String

limit

Object

Cannot be set when using bundles.

value

Float

Example

The following action applies a 20% discount to the amount of all the line items associated with an SKU among the ones grouped as discountable-items within the related condition matchers:

"actions": [
  {
    "type": "percentage",
    "selector": "order.line_items.sku",
    "groups": [ "discountable-items" ],
    "value": 0.2,  
  }
]

Value

The percentage to be discounted is defined by the value key which must be provided in decimal form as a float number between 0 and 1.

Maximum 4 decimals are allowed (e.g. 0.1535 corresponds to a 15.35% discount).

Restrictions

Resources

As regards the Rule Engine integration with Commerce Layer Core API, the percentage discount action type is available both for promotions (order rules) and price lists (price rules).

Last updated