Prioritize and Stack Rules
One of the principles of Price Rules is that when multiple rule sets interact, the customer will always receive the best (lowest) possible price. However, with the increasing complexity of pricing models, Price Rules offers the right price by leveraging the Prioritization and Stacking capabilities. In this tutorial we will walk through different examples of stacked rulesets and the final outcomes for the customer.
Prerequisites
During this tutorial, we review multiple rule sets with different product selection, conditions and actions.
For more technical information on using Priority, Stack Order, and Layer attributes, refer to the Attributes page.
Use Case Description
This is a fictional use case for demonstrational purposes only.
Bold Brew would like to offer an Employee Discount to reward their employees for all their hard work and dedication. However, they also run quantity based discounts for the number of beans as well as seasonal promotions. To ensure that the employees are being rewarded without the company losing money they are comparing different stacking configurations to determine the right price.
Base Price | Quantity Based Discount | Seasonal Sale | Employee Discount |
---|---|---|---|
Dark Roast Beans (1lb) = $15 | >= 5 lbs - 10% Discount | 5% off site wide | 20% off site wide |
No Prioritization
In this example, no prioritization is set. This means all discounts are applied on the same layer, and the greatest discount available will be applied to the product.
Rule Set - Quantity Based with No Prioritization
{
"ruleset": {
"external_id": "QUANTITY_BASED",
"internal_name": "Example of Quantity based Discount",
"product_selection": {
"type": "PRODUCT_SEARCH",
"sku_ids": ["CO-FF-EE"]
},
"rules": [
{
"type": "DISCOUNT",
"conditions": [
{
"type": "QTY_BY_PRODUCT",
"operator": ">=",
"value": 5
}
],
"actions": [
{
"type": "PRICE_ADJUST_PERCENT",
"value": -10
}
]
}
]
}
}
Rule Set - Seasonal Sale with No Prioritization
{
"ruleset": {
"external_id": "SEASONAL_SALE",
"internal_name": "Example of Seasonal Sale",
"start_date": "2020-11-23T00:00:00Z",
"expiry_date": "2022-11-30T23:59:00Z",
"product_selection": {
"type": "PRODUCTS_ALL"
},
"rules": [
{
"type": "DISCOUNT",
"conditions": [],
"actions": [
{
"type": "PRICE_ADJUST_PERCENT",
"value": -5
}
]
}
]
}
}
Rule Set - Employee Discount with No Prioritization
{
"ruleset": {
"external_id": "EMPLOYEE_DISCOUNT",
"internal_name": "Example of Employee Discount",
"product_selection": {
"type": "PRODUCTS_ALL"
},
"rules": [
{
"type": "DISCOUNT",
"conditions": [
{
"type": "CUSTOMER_GROUP",
"value": "Employee"
}
],
"actions": [
{
"type": "PRICE_ADJUST_PERCENT",
"value": -20
}
]
}
]
}
}
Final Price with No Prioritization
Base price | Final price per unit | Final discount |
---|---|---|
Dark Roast Beans (1lb) = $15 | $12 | 20% |
Discount Layers
In this example, Employee Discount will be applied last and will be applied above and beyond the best possible sale price for a regular customer.
This is achieved by indicating which Layer the discount applies to. By not indicating any priority for the Quantity based and Seasonal Sales they will apply on Layer 2 - DISCOUNT by default. In this layer only the best discount will be applied. Then when that price is resolved, the Employee Discount on Layer 3 - STACKABLE_DISCOUNT will be applied, offering the additional 20% off on top of the sale price.
Rule Set - Quantity Based with Discount Layers
{
"ruleset": {
"external_id": "QUANTITY_BASED",
"internal_name": "Example of Quantity based Discount",
"product_selection": {
"type": "PRODUCT_SEARCH",
"sku_ids": ["CO-FF-EE"]
},
"rules": [
{
"type": "DISCOUNT",
"conditions": [
{
"type": "QTY_BY_PRODUCT",
"operator": ">=",
"value": 5
}
],
"actions": [
{
"type": "PRICE_ADJUST_PERCENT",
"value": -10
}
]
}
]
}
}
Rule Set - Seasonal Sale with Discount Layers
{
"ruleset": {
"external_id": "SEASONAL_SALE",
"internal_name": "Example of Seasonal Sale",
"start_date": "2020-11-23T00:00:00Z",
"expiry_date": "2022-11-30T23:59:00Z",
"product_selection": {
"type": "PRODUCTS_ALL"
},
"rules": [
{
"type": "DISCOUNT",
"conditions": [],
"actions": [
{
"type": "PRICE_ADJUST_PERCENT",
"value": -5
}
]
}
]
}
}
Rule Set - Employee Discount with Discount Layers
{
"ruleset": {
"external_id": "EMPLOYEE_DISCOUNT",
"internal_name": "Example of Employee Discount",
"product_selection": {
"type": "PRODUCTS_ALL"
},
"rules": [
{
"type": "STACKABLE_DISCOUNT",
"conditions": [
{
"type": "CUSTOMER_GROUP",
"value": "Employee"
}
],
"actions": [
{
"type": "PRICE_ADJUST_PERCENT",
"value": -20
}
],
"stack_order": 1
}
]
}
}
Final Price with Discount Layers
Base price | Site Discounts (Layer 2) | Subtotal Price per unit | Employee Discounts (Layer 3) | Final Price per unit |
---|---|---|---|---|
Dark Roast Beans (1lb) = $15 | 10% off | $13.50 | 20% | $10.80 |
All Discounts Applied In Sequence
In this last example, all 3 discount types will be resolved in a specific order. There will be no competition between rules to determine best price. To apply all discounts, rather than the best discounts, all rules must be defined as part of Layer 3 - STACKABLE_DISCOUNT. We will apply the Quantity Based Discount on the product first, then the Employee Discount, and lastly the Seasonal Discount.
Rule Set - Quantity Based in Sequence
{
"ruleset": {
"external_id": "QUANTITY_BASED",
"internal_name": "Example of Quantity based Discount",
"product_selection": {
"type": "PRODUCT_SEARCH",
"sku_ids": ["CO-FF-EE"]
},
"rules": [
{
"type": "STACKABLE_DISCOUNT",
"conditions": [
{
"type": "QTY_BY_PRODUCT",
"operator": ">=",
"value": 5
}
],
"actions": [
{
"type": "PRICE_ADJUST_PERCENT",
"value": -10
}
],
"stack_order": 1
}
]
}
}
Rule Set - Employee Discount in Sequence
{
"ruleset": {
"external_id": "EMPLOYEE_DISCOUNT",
"internal_name": "Example of Employee Discount",
"product_selection": {
"type": "PRODUCTS_ALL"
},
"rules": [
{
"type": "STACKABLE_DISCOUNT",
"conditions": [
{
"type": "CUSTOMER_GROUP",
"value": "Employee"
}
],
"actions": [
{
"type": "PRICE_ADJUST_PERCENT",
"value": -20
}
],
"stack_order": 2
}
]
}
}
Rule Set - Seasonal Sale in Sequence
{
"ruleset": {
"external_id": "SEASONAL_SALE",
"internal_name": "Example of Seasonal Sale",
"start_date": "2020-11-23T00:00:00Z",
"expiry_date": "2022-11-30T23:59:00Z",
"product_selection": {
"type": "PRODUCTS_ALL"
},
"rules": [
{
"type": "STACKABLE_DISCOUNT",
"conditions": [],
"actions": [
{
"type": "PRICE_ADJUST_PERCENT",
"value": -5
}
],
"stack_order": 3
}
]
}
}
Final Price in Sequence
Base price | Quantity Discount (Layer 3) | Employee Discounts (Layer 3) | Seasonal Discounts (Layer 3) | Final Price per unit |
---|---|---|---|---|
Dark Roast Beans (1lb) = $15 | 10% | 20% | 5% | $10.26 |
For more technical information on using Priority, Stack Order, and Layer attributes please see article Attributes.