Discount items with large stock availability
Rule breakdown, resource payload analysis, and outcomes explanation
This rule applies a discount to specific line items in an order based on their quantity. The inventory of all the order's line item associated with an SKU is checked and a percentage discount is applied to those whose stock quantity 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 associated with SKUs whose stock quantity is greater than or equal to 100
. The line items that match the condition are grouped as discountable-items
.
Actions
The only action in the rule applies a 5% 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 3 of which are associated with an SKU. 2 of those SKUs (ZXxPSkbpNP
and HXxPSkbpNA
, associated with the line items wLGtgmdLjJ
and qLGtgmdLjC
) have a quantity
that matches or exceeds the desired threshold (200
and 100
respectively), 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 item IDs (together with the IDs of the related SKUs and the ID of the order) to which the discount is applied are listed within the matches
array. The action is applied to those line items with the decimal value of 0.05
corresponding to the specified percentage discount.
Conclusion
The rule successfully identifies the line items eligible for the discount and applies a 5% discount to each qualifying line item.
Last updated