Discount specific SKUs for new clients
Rule breakdown, resource payload analysis, and outcomes explanation
This rule discounts the price of the SKUs belonging to a given set for logged clients who are placing their first order. The SKU code and total number of orders already associated with the customer are checked. If the customer has no order associated yet and the SKU code matches one of the codes listed in the provided array, a percentage discount is applied to the related price. If you apply this rule to a price list that contains prices associated with one or more of the given SKU codes, those prices will be discounted for customers who have not made any previous orders.
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 total order count of the logged customer is
0
, ensuring that the customer is placing their first order.The second condition checks if the SKU code associated with the price is one of
JERSEYBLACK
orJERSEYGREEN
, to identify if the SKU is eligible for the discount. The prices that match this condition are grouped asjerseys
.
Since no conditions_logic
is specified, the default value and
will be used.
Actions
The only action in the rule is triggered if both the conditions are met and applies a 20% discount to the prices that match the second condition only (i.e. the ones belonging to the jerseys
group).
Resource payload analysis
The provided payload contains 3 prices, all associated with a logged customer who placed no order before. One of those prices (klzEhmRAMM
) is associated with an SKU whose code is JERSEYBLACK
, another (lpeNYUvMTO
) with an SKU whose code is JERSEYGREEN
, the remaining one with a different SKU code.
Result check
The outcomes reflect the evaluation of the rules against the resource payload. Since all the prices satisfy the first condition and 2 of them also satisfy the second condition, the rule matches successfully (match
is true
). The 3 price IDs are all listed in the matches
array of the first condition, along with the ID of the logged customer. The IDs of the two prices associated with the SKUs eligible for the discount are listed in the matches
array of the second condition. Action is applied to those 2 prices (i.e. to the group jerseys
) with a decimal value of 0.2
corresponding to the specified percentage discount.
Conclusion
The rule matches the provided price payload and successfully identifies two prices associated with a new customer and with the SKU codes provided. Consequently, a 20% discount is applied to both prices. The third price in the payload won't be discounted because, even if it is associated with a new customer, it doesn't belong to an SKU eligible for the discount.
Last updated