Discount line items based on item's price
Rule breakdown, resource payload analysis, and outcomes explanation
This rule applies a discount to specific line items in an order based on their price. All the order's line item amounts are checked and a fixed amount discount is applied to those whose amount is greater than or equal to a specific value.
The example below is based on the following reference JSONs. Once the rules are evaluated against the resource payload, the outcomes show if and how the conditions are matched and the related actions applied.
Rules breakdown
The desired results can be achieved with a single rule.
Conditions
The only condition in the rule checks if the order contains line items whose amount is greater than or equal to 9999 cents. The line items that match the condition are grouped as discountable-items
.
Actions
The only action in the rule applies a 2500 cents fixed amount discount to the order's line items that match the condition (i.e. the ones belonging to the discountable-items
group).
Resource payload analysis
The provided payload contains an order with 4 line items 2 of which (wLGtgmdLjJ
and qLGtgmdLjC
) have an amount greater than 9999 cents, thus qualifying for the discount.
Outcomes check
The outcomes reflect the evaluation of the rules against the resource payload. Since the order contains at least one line item that satisfies the condition, the rule matches successfully (match
is true
). The two line items to which the discount is applied are listed within the matches
array, together with the order ID. The action is applied to those line items based on their quantity (2
for wLGtgmdLjJ
and 1
for qLGtgmdLjC
).
Conclusion
The rule successfully identifies the line items eligible for the discount and applies the appropriate discount amounts to each qualifying line item, resulting in a cumulative discount of 7500 cents (2500 x 2 = 5000 for line item wLGtgmdLjJ
and 2500 x 1 = 2500 for line item qLGtgmdLjC
).
Last updated