Aggregation
How to aggregate the targets of an action
The selected items on which an action should apply can be aggregated based on another field's values. Those values are aggregated using a specified operator and the results of the aggregation is compared against a provided value using the aggregation's matcher to add additional restrictions and define the overall aggregated items on which to apply the action.
Unlike the condition's aggregations
key, which is an array of aggregation objects, an action's aggregation
key is a single object (with the same structure).
The allowed aggregation field
values are limited by the related action's selector
value, meaning that the former must be within the scope defined by the latter (i.e. an attribute of one of the entities specified in the action's selector). For example, if the action's selector is order.line_items
you can aggregate over order.line_items.quantity
but not over order.customer.total_orders_count
because the customer entity is not within the scope set by the selector.
Example
The following action applies a 30% discount to the order's line items labeled as discountable-items
by the related conditions only if the sum of their total amounts doesn't exceed 4500 cents.
Last updated