XM

Add Items to Cart

Path:

POST /cart-decoupled/item

This API enables your customers to add new items to their digital cart. With the first item in the cart, a unique cartId is generated, to be used for the subsequent calls. In response, this endpoint retrieves the details of individual items in the cart such as pricing, quantity, weight, taxCode, unit of measure, created & updated time stamp, etc. along with the applicable promotional codes.

Note: userAuthToken is required only for logged in user (not applicable for guest user).

Headers

x-site-context : { "date": "2020-08-28T02:35:27.787Z", "channel": 12, "account": 5f493c9f30ec2a0007a94fc8", "stage": "sandbox" }

Parameters

Type : body

Name : Add items to cart

Required: true

Sample Request (Add Item To Cart -Guest user)

The use case is a guess user adding item to the cart. Hence, userAuthToken is null. For a logged in user, userAuthToken must be specified. In the response for the logged in user, userID is additionally included.

{
"cartId": null,
"userAuthToken": null,
"registeredUser": false,
"items": [
{
"itemId": 1000000000,
"sku": "sk231212",
"taxCode": "TC1234567890",
"title": "Fabric t-shirt",
"weight": 4.2,
"quantity": 2,
"group": [
"5e2f45ae0aefb70008e96c40"
],
"price": {
"sale": null,
"base": 19,
"discount": {
"price": 0,
"discountAmount": 0,
"promosApplied": []
},
"currency": "USD"
},
"extra": {}
}
]
}
‚Äč

Sample Response

Response Code: 200

Message: OK

{
"_id": "5f5be987a99a54da8f13525a",
"deleted": false,
"registeredUser": false,
"cartId": 179,
"items": [
{
"price": {
"discount": {
"discountAmount": 0,
"price": 0,
"promosApplied": []
},
"sale": 0,
"base": 19,
"currency": "USD"
},
"discountedQuantity": 0,
"group": [
"5e2f45ae0aefb70008e96c40"
],
"weightUnit": "lb",
"createdAt": "2020-09-09T16:43:22.763Z",
"updatedAt": "2020-09-09T16:43:22.763Z",
"_id": "5f5be987a99a54da8f13525b",
"itemId": 1000000000,
"sku": "sk231212",
"taxCode": "TC1234567890",
"title": "fabric t-shirt",
"weight": 4.2,
"quantity": 2,
"lineItemId": 1,
"totalPrice": {
"currency": "USD",
"amount": 38
},
"id": "5f5be987a99a54da8f13525b"
}
],
"allPromosApplied": [],
"createdAt": "2020-09-11T21:17:59.476Z",
"updatedAt": "2020-09-11T21:17:59.477Z",
"__v": 0,
"totalAmount": {
"currency": "USD",
"amount": 38
},
"quantity": 2
}

Response Code: 400

Message: Bad Request - Missing Required Attribute

Error Code: 403

Message: Forbidden

Description: You will see this error when the account number is incorrect in the x-site-context (for a multi-tenent client).

{
"message": "Forbidden"
}

Change Log

  • June - 2021

  • July - 2020 First updated