Discounting bundles
Prerequisites
- Create your Integration API key.
- If you haven't done so already, fork our Sample Campaigns collection in Postman:
- In the Campaign Manager, open the ADVANCED-BUNDLE: $50 off bundled products demo campaign and click Activate Campaign.
- Open the Rule Builder to get some context.
Let's create a promotion rule that awards customers with a $50 pro-rata discount per bundle of one bike + two helmets found in their sessions.
Creating the promotion
Cart item filters
Let's start by creating the cart item filters. We need them to identify helmets and bikes. Then we'll create a bundle based on these items. We've already used cart item filters to check the category of cart items in the Different discounts for different categories tutorial.
-
Click Add Filter.
-
Click Add Filter Step and select Filter items by condition.
-
Set the filter to Item category (Item) is equal to
Road Bikes
. -
In Save As, type
RoadBikes
and click Save Filter.This cart item filter returns a list of cart items.
Repeat the same steps to create a filter to find items in the Helmets
category and count them.
Creating the bundle definition
To bundle the items, let's create a bundle definition:
- Click Bundle Definitions > Add Bundle Definition.
- In Name, type
1RoadBike2Helmets
. - In List of cart items, select RoadBikes and choose 1 item.
- Click Add list.
- In List of cart items, select Helmets and choose 2 item.
We have a bundle definition composed of one item from our RoadBikes
cart item filter,
and two items from the Helmets
cart item filter. The bundle definition will create as
many bundles as possible from the current state of the cart.
We know how many bundles are created thanks to the Count (1RoadBike2Helmets) attribute. This attribute is created automatically with the bundle definition.
Rule
Let's create the rule to trigger the discount:
-
Condition: Check attribute value and compose the following expression: Count (1RoadBike2Helmets)
is greater than or equal to 1
This check that our bundle definition managed to create a least one bundle.
-
Effect: Discount bundles pro rata and select:
- Bundle definition:
1RoadBike2Helmets
- Discount Name:
$50 off a bundle of items
- Discount value for each bundle:
50
- Bundle definition:
Running the campaign
To run the campaign, we send a suitable session to the Integration API's Update customer session endpoint.
- 🚀 Request
- ✅ Response
The session contains two helmets and one road bike, which is the bundle definition.
CURL -X PUT https://mycompany.europe-west1.talon.one/v2/customer_sessions/my_session_id -d
'{
"customerSession": {
"profileId": "{{integrationId}}",
"state": "closed",
"cartItems": [
{
"name": "ProductC",
"sku": "sku-00004",
"quantity": 2,
"price": 200,
"Category": "Road Bikes",
"weight": 0,
"position": 0,
"attributes": {}
},
{
"name": "ProductD",
"sku": "sku-00005",
"quantity": 1,
"price": 49.99,
"Category": "Helmets",
"weight": 0,
"position": 0,
"attributes": {}
},
{
"name": "ProductE",
"sku": "sku-00006",
"quantity": 1,
"price": 39.99,
"Category": "Helmets",
"weight": 0,
"position": 0,
"attributes": {}
}
],
"couponCodes": [
""
],
"referralCode": "",
"attributes": {},
"additionalCosts": {}
},
"responseContent": []
}'
We receive this response, which shows the setDiscountPerItem
effect for each item.
As we saw in the Different discounts for different categories tutorial,
the position
property represents which item is impacted by the effect based
on the item's position in the cartItems
array sent in the update request.
{
"createdCoupons": [],
"createdReferrals": [],
"effects": [
{
"campaignId": 245,
"rulesetId": 493,
"ruleIndex": 0,
"ruleName": "$50 on Bundle: 1 Road Bike & 2 Helmets",
"effectType": "setDiscountPerItem",
"props": {
"name": "$50 off a bundle of items#0",
"value": 99.99,
"position": 0,
"subPosition": 0,
"totalDiscount": 144.990,
"bundleIndex": 0,
"bundleName": "1RoadBike2Helmets"
}
},
{
"campaignId": 245,
"rulesetId": 493,
"ruleIndex": 0,
"ruleName": "$50 on Bundle: 1 Road Bike & 2 Helmets",
"effectType": "setDiscountPerItem",
"props": {
"name": "$50 off a bundle of items#1",
"value": 25.00,
"position": 1,
"subPosition": 0,
"totalDiscount": 144.990,
"bundleIndex": 0,
"bundleName": "1RoadBike2Helmets"
}
},
{
"campaignId": 245,
"rulesetId": 493,
"ruleIndex": 0,
"ruleName": "$50 on Bundle: 1 Road Bike & 2 Helmets",
"effectType": "setDiscountPerItem",
"props": {
"name": "$50 off a bundle of items#2",
"value": 20.00,
"position": 2,
"subPosition": 0,
"totalDiscount": 144.990,
"bundleIndex": 0,
"bundleName": "1RoadBike2Helmets"
}
}
]
}
- You can bundle items with a cart item filter or use the bundle feature.