Discount all the SKU in an order based on the shipping country
Rule breakdown, resource payload analysis, and outcomes explanation
This rule applies a discount to all the products present in an order if shipped to a specific country. The country code of the shipping address associated with the order is checked and a percentage discount is applied to all the line items associated with an SKU if the conditions are met.
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 country_code
attribute of the shipping address associated with the order is equal to DE
. (i.e. if the items in the order are going to be shipped to Germany)
Actions
The only action in the rule applies a 20% discount to the order's line items that are associated with an SKU.
Resource payload analysis
The payload contains an order with a shipping address where the country code is DE
. This matches the condition specified in the rule, confirming that the order qualifies for the discount. The order contains 5 line items, 4 of which (wLGtgmdLjJ
, zbZtmarXKR1
, zbZtmarXKR2
, and aoMtJlQlxD
) are associated with an SKU (ZXxPSkbpNP
, WVyPSgRwxd
, WVyPSgRwxZ
, and WKjRSMmlxe
respectively).
Outcomes check
The outcomes reflect the evaluation of the rules against the resource payload. Since the order's shipping address satisfies the condition, the the rule matches successfully (match
is true
) and the order and related shipping address IDs are listed within the matches
array. The action is applied to the line items associated with an SKU with the decimal value of 0.2
corresponding to the specified percentage discount.
Conclusion
Once checked that the order's shipping country is the desired one, the rule successfully identifies the line items eligible for the discount and applies a 20% discount to each qualifying line item.
Last updated