Discount an order based on promo item and total number of items
Rule breakdown, resource payload analysis, and outcomes explanation
This rule applies a discount to an order based on which items it contains and how many. All the order's line item SKU codes are checked to find a specific promotional product. The total number of SKUs in the order is also checked. A percentage discount is applied to the order's total amount 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 order contains a line item associated with an SKU whose code is
PROMOTSHIRT
.The second condition checks if the order contains at least 3 SKUs by inspecting the
skus_count
attribute.
Since no conditions_logic
is specified, the default value and
will be used.
Actions
The only action in the rule applies a 10% discount to the whole order amount if both the conditions are met.
Resource payload analysis
The provided payload contains an order with 3 line items of which only 2 (dKdhYLlzgE
and eKfhYFkztQ
) are associated with an SKU code (PROMOTSHIRT
and BLACKHOODIEM
respectively). Hence the order contains the promotional product (i.e. it matches the first condition) but doesn't reach the minimum number of SKUs in total to match the second condition.
Outcomes check
The outcomes reflect the evaluation of the rules against the resource payload. Since the order's payment source satisfies only one of the two conditions, the rule doesn't match (match
is false
). The first condition is met and the IDs of the order and of the line item associated with the promotional product are listed within the related matches
array. The second condition isn't met so the related matches
array is empty. Consequently, the actions
array is also empty and the desired action is not applied.
Conclusion
The rule doesn't match the provided order payload. Consequently, even if the promotional product is present, no discount is applied due to the total number of SKUs in the order being under the specified threshold.
Last updated