XM

Update Cart

Path:

PATCH https://{baseurl}/api-cart/cart/{cartId}/items

The ideal use case for this API is to allow your customers to decrement the quantity of an item in their cart, any time before billing. If the requested quantity is not in stock, the API still returns a success response but the inventory error is displayed in the 'errors' object within the success response.

To add new items or increment item quantity, the Add Items to Cart API is used. To remove existing items, the Remove Item from Cart API is used.

Headers

Content-Type : application/json

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

Parameters

Type : path

Name : The 24 character system-generated cart ID (from the Add Items to Cart or Retrieve Cart by userAuthToken API).

Required: true

Type : requestBody

Name : The item details to be updated.

Required: true

Sample Request

Path:

PATCH https://{baseurl}/api-cart/cart/607f8a8f0118960009a8e6ee/items

Request Body:

{
"items": [
{
"lineItemId": 1,
"itemId": 1000000050,
"quantity": 10,
"price": {
"sale": 0,
"base": 1000,
"discount": {
"price": 0,
"discountAmount": 0,
"promosApplied": []
},
"currency": "USD"
}
}
]
}

Sample Response

Success Code: 200

Message: OK

Description: You'll see this message when the cart is successfully updated.

{
"_id": "607f8a8f0118960009a8e6ee",
"deleted": false,
"registeredUser": true,
"cartId": 1475,
"items": [
{
"price": {
"discount": {
"discountAmount": 0,
"price": 0,
"promosApplied": []
},
"sale": 0,
"base": 900,
"currency": "USD"
},
"sample": false,
"discountedQuantity": 0,
"group": [
"123123123123123213212222"
],
"weightUnit": "lb",
"isPickup": false,
"createdAt": "2021-04-21T02:14:38.620Z",
"updatedAt": "2021-04-21T18:04:12.902Z",
"_id": "607f8a8f0118960009a8e6ef",
"itemId": 1000000051,
"quantity": 3,
"priceListId": 100269,
"sku": "1538910",
"taxCode": "PH060771",
"title": "Luminous Cushion Lagoon",
"weight": 1,
"lineItemId": 1,
"attributeTotalPrice": 0,
"totalPrice": {
"currency": "USD",
"amount": 2700
},
"attributes": [],
"id": "607f8a8f0118960009a8e6ef"
},
{
"price": {
"discount": {
"discountAmount": 0,
"price": 0,
"promosApplied": []
},
"sale": 48,
"base": 148,
"currency": "USD"
},
"sample": false,
"discountedQuantity": 0,
"group": [
"123123123123123213212222"
],
"weightUnit": "lb",
"isPickup": false,
"createdAt": "2021-04-21T02:14:38.620Z",
"updatedAt": "2021-04-21T18:04:12.902Z",
"_id": "607f8a8f0118960009a8e6f0",
"itemId": 1000000052,
"quantity": 2,
"priceListId": 100269,
"sku": "1583908",
"taxCode": "PH060771",
"title": "Embellished Pillow Pink",
"weight": 1,
"lineItemId": 2,
"attributeTotalPrice": 0,
"totalPrice": {
"currency": "USD",
"amount": 96
},
"attributes": [],
"id": "607f8a8f0118960009a8e6f0"
}
],
"userId": "600a56593245200007982fac",
"allPromosApplied": [],
"attributes": [],
"createdAt": "2021-04-21T02:14:39.048Z",
"updatedAt": "2021-04-21T18:04:12.932Z",
"__v": 0,
"totalAmount": {
"currency": "USD",
"amount": 2796
},
"quantity": 5,
"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": []
}
}

Error Code: 404

Message: Not found

Description: You will see this error when the specified cart ID doesn't exist in the system.

{
"code": "CART_NOT_FOUND",
"message": "Cart not found."
}

Error Code: 400

Message: Request validation

Description: You will see this error when the specified cart ID is lesser or greater than 24 characters.

{
"code": "REQUEST_VALIDATION",
"message": "Invalid data in path: /cartId should NOT be shorter than 24 characters"
}

Error Code: 500

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"
}

Error Code: 500

Message: Internal Server Error

Description: You will see this error when the item to be updated is already in cart with a different lineItemId.

{
"message": "Cannot read property 'attributes' of undefined"
}

Error Code: 500

Message: Internal Server Error

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

Change Log

  • June - 2021

  • July - 2020 First updated