Rule Examples
Ready-to-use JSON payloads for common rule types. POST each example to the rules endpoint, adapting the filter, comment, and executionIndex for your use case.
See the API Reference for a full explanation of every field.
Examples in this article:
DisableProduct
Disables product 12345 for eat-in orders on weekdays, across all stores in GB and SE.
{
"comment": "disable 12345-TheBestUpsellProduct on weekdays for all stores",
"filter": {
"products": {
"appliesTo": "specific",
"values": [
12345
]
},
"stores": {
"appliesTo": "all"
},
"storeCountryIsoCodes": {
"appliesTo": "specific",
"values": [
"GB",
"SE"
]
},
"orderClasses": {
"appliesTo": "specific",
"values": [
"EatIn"
]
},
"daysOfWeek": {
"appliesTo": "specific",
"values": [
"monday",
"tuesday",
"wednesday",
"thursday",
"friday"
]
}
},
"activeDuring": {
"timeOfDay": {
"applies": "always"
},
"dates": {
"applies": "always"
}
},
"type": "DisableProduct",
"executionIndex": 74
}
EnableProduct
Enables product 12345 for eat-in orders on weekdays. Useful in combination with a disableProduct rule that disables the product by default.
{
"comment": "enable 12345-TheBestUpsellProduct on weekdays for all stores",
"filter": {
"products": {
"appliesTo": "specific",
"values": [
12345
]
},
"stores": {
"appliesTo": "all"
},
"storeCountryIsoCodes": {
"appliesTo": "specific",
"values": [
"GB",
"SE"
]
},
"orderClasses": {
"appliesTo": "specific",
"values": [
"EatIn"
]
},
"daysOfWeek": {
"appliesTo": "specific",
"values": [
"monday",
"tuesday",
"wednesday",
"thursday",
"friday"
]
}
},
"activeDuring": {
"timeOfDay": {
"applies": "always"
},
"dates": {
"applies": "always"
}
},
"type": "EnableProduct",
"executionIndex": 76
}
UpsellProduct
Triggers an upsell screen at checkout recommending product 12345, regardless of what is in the basket.
{
"comment": "Upsell from any product or any categories for all stores to 12345-TheBestUpsellProduct",
"recommendations": {
"triggerEvent": "checkout",
"shownOnPage": 1,
"productIds": [
12345
],
"ifInBasket": "recommendAnyway"
},
"filter": {
"products": {
"appliesTo": "all"
},
"categories": {
"appliesTo": "all"
},
"stores": {
"appliesTo": "all"
},
"storeCountryIsoCodes": {
"appliesTo": "specific",
"values": [
"GB",
"SE"
]
},
"orderClasses": {
"appliesTo": "specific",
"values": [
"EatIn"
]
},
"daysOfWeek": {
"appliesTo": "all"
}
},
"activeDuring": {
"timeOfDay": {
"applies": "always"
},
"dates": {
"applies": "always"
}
},
"type": "UpsellProduct",
"executionIndex": 73
}
UpsellCategory
Triggers an upsell screen at checkout recommending category 42, regardless of what is in the basket.
{
"comment": "Upsell from any product or any categories for all stores to 42-TheBestUpsellCategory",
"recommendations": {
"triggerEvent": "checkout",
"shownOnPage": 1,
"categoryIds": [42],
"ifInBasket": "recommendAnyway"
},
"filter": {
"products": {
"appliesTo": "all"
},
"categories": {
"appliesTo": "all"
},
"stores": {
"appliesTo": "all"
},
"storeCountryIsoCodes": {
"appliesTo": "specific",
"values": [
"GB",
"SE"
]
},
"orderClasses": {
"appliesTo": "specific",
"values": [
"EatIn"
]
},
"daysOfWeek": {
"appliesTo": "all"
}
},
"activeDuring": {
"timeOfDay": {
"applies": "always"
},
"dates": {
"applies": "always"
}
},
"type": "UpsellCategory",
"executionIndex": 73
}
Stockout
Marks product 12345 as stocked out at stores 222 and 111.
For stockout constraints (single rule per store, update-in-place, and batching), see Stockout.
{
"comment": "stockout 12345 for store 222 and 111",
"filter": {
"products": {
"appliesTo": "specific",
"values": [
12345
]
},
"stores": {
"appliesTo": "specific",
"values": [
"222",
"111"
]
},
"storeCountryIsoCodes": {
"appliesTo": "all"
},
"orderClasses": {
"appliesTo": "all"
},
"daysOfWeek": {
"appliesTo": "all"
}
},
"activeDuring": {
"timeOfDay": {
"applies": "always"
},
"dates": {
"applies": "always"
}
},
"type": "Stockout",
"executionIndex": 75
}