XM

Empty Cart

Path:

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

This API supports emptying of the cart based on the specified cartId. In this case, the cart continues to exist, but with 0 item in it. For deleting the cart altogether, the Delete Cart endpoint 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 cartID (from the Add Items to Cart or Retrieve Cart by userAuthToken API)

Required: true

Sample Request

Path:

https://{baseurl}/api-cart/cart/60806e0b2b71680009000e0d/empty

Sample Response

Response Code: 200

Message: OK

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

{
"_id": "60806e0b2b71680009000e0d",
"deleted": false,
"registeredUser": false,
"cartId": 1491,
"items": [],
"allPromosApplied": [],
"attributes": [],
"createdAt": "2021-04-21T18:25:15.947Z",
"updatedAt": "2021-04-21T19:05:50.431Z",
"__v": 0,
"totalAmount": {
"currency": "",
"amount": 0
},
"quantity": 0
}

Response Code: 404

Message: Not found

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

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

Response Code: 400

Message: Request validation

Description: You will see this error when the 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"
}

Response Code: 400

Message: Bad Request

Description: You will see this error when the cart is already empty.

{
"code": "EMPTY_CART_ERROR",
"message": "The cart is already empty."
}

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