XM

Add Items to Cart

Path:

POST /cart/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" }

Consumes

  • application/json

Produces

  • application/json

Parameters

Type : body

Name : Add items to cart

Required: true

Sample Request (Add Item To Cart -Guest user)

This use case is applicable when the user adds item to the cart as the guest user. 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": 1000000038,
"priceListId": 100269,
"quantity": 2,
"group": [
"{{groupId}}"
],
"price": {
"sale": 0,
"base": 1000,
"discount": {
"price": 0,
"discountAmount": 0,
"promosApplied": []
},
"currency": "USD"
},
"extra": {}
}
]
}

Sample Response

Response Code: 200

Message: OK

Description: You will see this message when items selected are successfully added to the cart.

{
"_id": "606081e53dbe77000881c2ca",
"deleted": false,
"registeredUser": false,
"cartId": 1254,
"items": [
{
"price": {
"discount": {
"discountAmount": 0,
"price": 0,
"promosApplied": []
},
"sale": 0,
"base": 900,
"currency": "USD"
},
"sample": false,
"discountedQuantity": 0,
"group": [
"5ecef789df21ae00077e7a2f"
],
"weightUnit": "lb",
"createdAt": "2021-03-28T13:17:24.938Z",
"updatedAt": "2021-03-28T13:17:29.503Z",
"_id": "606081e53dbe77000881c2cb",
"itemId": 1000000051,
"priceListId": 100269,
"quantity": 2,
"sku": "1538910",
"taxCode": "PH060771",
"title": "Luminous Cushion Lagoon",
"weight": 1,
"lineItemId": 1,
"attributeTotalPrice": 0,
"totalPrice": {
"currency": "USD",
"amount": 1800
},
"attributes": [],
"id": "606081e53dbe77000881c2cb"
}
],
"allPromosApplied": [],
"attributes": [],
"createdAt": "2021-03-28T13:17:25.353Z",
"updatedAt": "2021-03-28T13:17:29.514Z",
"__v": 0,
"totalAmount": {
"currency": "USD",
"amount": 1800
},
"quantity": 2,
"errors": {
"inventory": [],
"price": [
{
"_id": "60133c1d93dfc60007ec11d7",
"priceListId": 100269,
"itemId": 1000000051,
"offers": [
{
"price": {
"sale": 0,
"cost": 580,
"currency": "USD",
"base": 900,
"discount": {
"discountAmount": 0,
"price": 0,
"promosApplied": []
}
},
"_id": "605b8623dbdb92000746d766",
"kind": null,
"channel": 12,
"startDate": "2021-03-24T19:15:00.000Z",
"endDate": "2100-01-01T07:59:00.000Z",
"offerCode": 4166800
}
]
}
],
"promo": []
}
}

Response Code: 404

Message: Not in stock

Changelog

  • April-2021 last updated

  • July-2020 First updated

‚Äč