Discount all the SKU in an order based on the customer email domain
Rule breakdown, resource payload analysis, and outcomes explanation
This rule applies a discount to all the products present in an order if the customer's email belongs to one of two provided domains. The email address of the customer who's placing 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 rule contains two conditions:
The first condition checks if the email address associated with the order ends with
@mybrand.com
.The second condition checks if the email address associated with the order ends with
@example.com
.
The conditions_logic
is set to or
, meaning that if either condition is met, the rule will be applied.
Actions
The only action in the rule is triggered if any of the conditions are met and applies a 15% discount to all the line items associated with an SKU.
Resource payload analysis
The payload contains an order placed by a customer whose email address is john.doe@mybrand.com
. This matches the first 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).
Result check
The outcomes reflect the evaluation of the rules against the resource payload. Since the order's customer email satisfies one of the two conditions the order ID is listed within the related matches
array. This doesn't happen for the second condition, but being the conditions evaluated according to an or
logic the rule matches successfully anyway (match
is true
). The action is applied to the line items associated with an SKU with the decimal value of 0.15
corresponding to the specified percentage discount.
Conclusion
Once checked that the order's customer email address belongs to the desired domain, the rule successfully identifies the line items eligible for the discount and applies a 15% discount to each qualifying line item.
Last updated