XM

Add Attributes To Cart

Path:

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

Enables your customers to opt for additional services (such as gift wrapping) at cart-level. If a gift-wrapping service is selected at the cart-level, all the items in the cart are wrapped in a single gift wrap.

To avail the same gift wrap service for one or more items in the cart (not all), the Add Attributes To Cart Items API is recommended.

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: Body

Name: The attribute details.

Required: true

Sample Request

Path:

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

Request Body:

[
{
"attributeId": "60b12fdda12cde00081b4f80",
"attributeValue":"false"
}
]

Response

Success Code: 200

Message: OK

Description: You'll see this message when the stripe payment is successfully added to the cart.

{
"_id": "60b12e29fbe918000871a8c7",
"deleted": false,
"registeredUser": false,
"cartId": 1091,
"items": [
{
"price": {
"discount": {
"discountAmount": 0,
"price": 0,
"promosApplied": []
},
"sale": 0,
"base": 1000,
"currency": "USD"
},
"sample": false,
"discountedQuantity": 0,
"group": [
"123123123123123213212222"
],
"weightUnit": "kg",
"isPickup": false,
"createdAt": "2021-05-28T17:48:03.398Z",
"updatedAt": "2021-05-28T18:13:50.078Z",
"_id": "60b12e29fbe918000871a8c8",
"itemId": 1000000033,
"quantity": 2,
"priceListId": 100000,
"sku": "SHIRT001",
"taxCode": "TAX001",
"title": "Shirt",
"weight": 60,
"lineItemId": 1,
"attributeTotalPrice": 0,
"totalPrice": {
"currency": "USD",
"amount": 2000
},
"attributes": [],
"id": "60b12e29fbe918000871a8c8"
}
],
"allPromosApplied": [],
"attributes": [
{
"price": 5,
"_id": "60b132d69ea1b200097f513b",
"attributeId": "60b12fdda12cde00081b4f80",
"value": "true",
"name": "Complete Order Gift Warp Small",
"type": "bool",
"id": "60b132d69ea1b200097f513b"
}
],
"createdAt": "2021-05-28T17:53:45.750Z",
"updatedAt": "2021-05-28T18:13:50.089Z",
"__v": 0,
"totalAmount": {
"currency": "USD",
"amount": 2005
},
"quantity": 2,
"errors": {
"inventory": [],
"price": [],
"promo": []
}
}

Error Code: 404

Message: Not found

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

{
"message": "Cart not found.",
"statusCode": 404,
"code": "ATTRIBUTE_ERROR"
}

Error Code: 400

Message: Bad Request

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

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 First updated