Understanding cart item flattening
Cart item flattening is a process consisting in splitting each cart item whose quantity is greater than 1 into individual cart items.
Talon.One always flattens the cart items you send. This allows you and Talon.One to apply per-item effects to units of a given product, instead of only considering all the units of a given product.
For example, if you run a clothing company and a customer adds two T-shirts and three hats to their cart, Talon.One will flatten the cart items internally:
Per-item discounts are applied to each instance of the item. Using per-item effects, can lead to more triggered effects.
JSON representation of the flattening
Use the Update customer session endpoint to share the details of a session, and its cart items, to Talon.One.
Cart items are represented by the CartItems
array inside the payload, for example, if
a customer adds 3 units of a given item to their cart, you send the following payload
to Talon.One:
{
"customerSession": {
"profileId": "URNGV8294NV",
// ...
"state": "open",
"cartItems": [
{
"name": "Candle",
"sku": "SKU1241028",
"quantity": 3,
"price": 15.99,
}
]
}
Such cart is flattened internally by Talon.One to look as follows:
{
"customerSession": {
"profileId": "URNGV8294NV",
// ...
"state": "open",
"cartItems": [
{
"name": "Candle",
"sku": "SKU1241028",
"quantity": 1,
"price": 15.99,
},
{
"name": "Candle",
"sku": "SKU1241028",
"quantity": 1,
"price": 15.99,
},
{
"name": "Candle",
"sku": "SKU1241028",
"quantity": 1,
"price": 15.99,
},
]
}
As a result, if you use per-item effects, like a per-item discount applied to all items of the session, you receive three effects instead of one.