Actions
How to set a rule's actions and what are the required and optional parameters to set
Last updated
How to set a rule's actions and what are the required and optional parameters to set
Last updated
For each rule you need to provide one or more actions
as an array of action objects.
Actions are triggered based on the provided rule's . Once the combination of conditions are evaluated according to the conditions logic specified at the level, if they are satisfied, all the related actions will be applied to the specified resource's fields. Among other effects, actions can modify order totals, apply fixed, percentage, and other types of discounts to specific items, or adjust quantities.
For each action you must define at least its type and the discount value to be applied. Based on the some restrictions may apply, for example:
The list of required parameters may vary.
The required format/type for the value (if any) may vary.
Some optional key (e.g. bundle, limit, etc.) may be available or not.
type
"percentage"
selector
The resource on which to apply the action (expressed in dot notation). Can be an attribute if you set also the identifier
key.
"order.line_items"
"order.line_items.id"
identifier
An identifier value to address one or more specific instances of the resource based on the attribute defined in the selector
key (if any). Cannot be used if the selector is a resource.
"WVyPSgRwxZ"
groups
[ "discountable-items", "t-shirts" ]
bundle
Additional directives on how to recursively pick a subset of elements from the specified groups.
aggregation
Additional requirements on the aggregated items targeted by the action.
apply_on
The specific field of the selector resource on which to apply the action (available for specific action types only).
"compare_at_amount_cents"
discount_mode
"distributed"
limit
Additional restrictions on the number of items on which an action will be applied (available for specific action types only, cannot be used if the bundle
key is specified).
value
0.2
2500
{ "x": 3, "y": 2 }
Referring to the , an action selector
can be a resource or an attribute. If it's a resource (i.e. anything but the last leaf of the relationship tree using the dot notation — e.g. order
or order.line_items
) the action will be applied on a default field (usually the unit amount of the resource), unless specified differently in the apply_on
key. If it's an attribute (e.g. or order.line_items.id
), you need to set also the identifier
key (e.g. WVyPSgRwxZ
) so that the action will be applied to the specified instance only.
The following action applies a 10% discount to all the line items associated with an SKU:
The following action sets to 1500 cents the unit amount of the line items associated with the SKU identified by the code XMASMUG1234
only:
The following action applies a fixed amount discount of 1500 to the total amount (instead of the default unit amount) of all the line items associated with an SKU:
The following action applies a fixed amount discount of 1500 to the total amount (instead of the default unit amount) of the line items associated with the SKU identified by the code XMASMUG1234
only:
The type of action you want to apply (check the ).
The groups that will be targeted by the action (must be one or more among the ones defined when grouping the matches of the related conditions — required when using ).
Learn more .
Learn more .
The type of distribution of the discount over the selected items. Can be one of default
or distributed
, default is default
(available for actions only).
Learn more .
The amount or percentage (or any other format required) to be discounted (format and type may vary based on the ).
You can use apply_on
on , , and actions only.