XPM

Cart - Add Items to Cart

Path:

POST /cart/item

Through this endpoint, users can add new items to their digital cart. With the first item in the cart, a unique cartId is generated and that is required for the subsequent calls. In response, this endpoint retrieves the details of individual items in the cart such as pricing (base price and sale price), quantity, weight, taxCode, unit of measure, created & updated time stamp, etc. along with the applicable promotional codes.

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

‚Äč

Headers

Content-Type : application/json

x-site-context : {"date":"2020-06-12T13:16:09.000Z","channel":12}

Consumes

  • application/json

Produces

  • application/json

Parameters

Type : body

Name : Add items to cart

Required: true

Sample Request

{
"cartId": null,
"userAuthToken": null,
"registeredUser": false,
"items": [
{
"itemId": "1000000038",
"quantity": 2,
"group": [
"5e31a1f9fcc2b500089c10e8"
],
"price": {
"sale": 68,
"base": 85,
"discount": {
"price": 0
},
"currency": "USD"
},
"extra": {}
}
]
}

Response

Response Code: 200

Message: OK

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

Sample

{
"_id": "5f13872a65bc750008b5828d",
"deleted": false,
"registeredUser": false,
"cartId": 1531,
"items": [
{
"price": {
"discount": {
"price": 0,
"discountAmount": 0,
"promosApplied": []
},
"sale": 68,
"base": 85,
"currency": "USD"
},
"discountedQuantity": 0,
"group": [
"5e31a1f9fcc2b500089c10e8"
],
"weightUnit": "lb",
"createdAt": "2020-07-18T22:19:41.035Z",
"updatedAt": "2020-07-18T23:35:06.500Z",
"_id": "5f13872a65bc750008b5828e",
"itemId": 1000000038,
"quantity": 2,
"sku": "1554213",
"taxCode": "PH060771",
"title": "Glo Pillow Light Gray",
"weight": 2,
"lineItemId": 1,
"totalPrice": {
"currency": "USD",
"amount": 136
},
"id": "5f13872a65bc750008b5828e"
}
],
"allPromosApplied": [],
"createdAt": "2020-07-18T23:35:06.294Z",
"updatedAt": "2020-07-18T23:35:06.579Z",
"__v": 0,
"totalAmount": {
"currency": "USD",
"amount": 136
},
"quantity": 2,
"errors": {
"inventory": [],
"price": [],
"promo": []
}
}

Response Code: 400

Message: Bad Request

Description: You will see this message when there are discrepancies in the input data such as:

  • itemId, groupId are blank or invalid

  • Quantity is not 1 or above.

Response Code: 415

Message: Unsupported Media Type

Description: You will see this generic messge when the JSON file format is invalid.

Changelog

  • July-2020 last updated