Cart
The cart keeps track of items and discounts. When using Norce Commerce with the Norce adapter we can consider the entire cart owned by this adapter. We could potentially update the cart directly using the order api or by some other adapter, but the Norce adapter would ignore them and could potentially override them at any time. In most cases we simply want to update the cart using the Norce adapter or by updating Norce Commerce and then requesting the Norce adapter to update the cart.
Cart item
A cart item holds product information like display name, SKU, image URL, and checkout-related details such as quantity. Each item has three price types, presented in major units for both including and excluding VAT:
-
price
: The original unit price. -
originalTotal
: Quantity multiplied by the original unit price. -
total
: The final price the customer pays after discounts.
Cart example
In this example, two discounts are applied: one to the entire cart and another to a specific item.
For the first item, the original unit price is 300
, and since the quantity is 1
, the originalTotal
matches. A larger portion of the cart discount is applied to this item, as it is more expensive. The final total
reflects the originalTotal
minus all discounts.
For the second item, the original unit price is 100
, and since the quantity is 2
, the originalTotal
is doubled. This item only receives the cart discount, and the total reflects the originalTotal
minus that discount.
At the end, we find a summary of all discounts applied to the cart.
{
"items": [
{
"name": "First Item",
"quantity": 1,
"price": {
"includingVat": 300,
"excludingVat": 240
},
"originalTotal": {
"includingVat": 300,
"excludingVat": 240
},
"total": {
"includingVat": 220,
"excludingVat": 176
},
"vatRate": 0.25,
"discounts": [
{
"name": "Cart Discount",
"value": {
"includingVat": 60,
"excludingVat": 48
}
},
{
"name": "Item Discount",
"value": {
"includingVat": 20,
"excludingVat": 16
}
}
]
},
{
"name": "Second Item",
"quantity": 2,
"price": {
"includingVat": 100,
"excludingVat": 80
},
"originalTotal": {
"includingVat": 200,
"excludingVat": 160
},
"total": {
"includingVat": 160,
"excludingVat": 112
},
"vatRate": 0.25,
"discounts": [
{
"name": "Cart Discount",
"value": {
"includingVat": 40,
"excludingVat": 32
}
}
]
}
],
"discounts": [
{
"name": "Cart Discount",
"value": {
"includingVat": 100,
"excludingVat": 80
}
},
{
"name": "Item Discount",
"value": {
"includingVat": 20,
"excludingVat": 16
}
}
],
"total": {
"includingVat": 380,
"excludingVat": 240
}
}