XM

Add Attributes to Cart Items

Path:

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

Enables you to add attributes to various items in the cart.

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}/item/attribute

Request Body:

[
{
"lineItemId": 2,
"attributeId": "6092cba26fe410000872bc62",
"attributeValue":"true"
}
]

Response

Success Code: 200

Message: OK

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

{
"_id": "60b132ee41b0a000089fafda",
"deleted": false,
"registeredUser": false,
"cartId": 1092,
"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-28T18:33:50.644Z",
"updatedAt": "2021-05-28T18:40:28.791Z",
"_id": "60b1378f33ce7300086e67bd",
"itemId": 1000000050,
"quantity": 2,
"priceListId": 100000,
"sku": "WATCH123456",
"taxCode": "PAC12345",
"title": "Watch",
"weight": 2,
"lineItemId": 1,
"attributeTotalPrice": 50,
"totalPrice": {
"currency": "USD",
"amount": 2000
},
"attributes": [
{
"price": 25,
"_id": "60b139053e2387000936c48e",
"attributeId": "6092cba26fe410000872bc62",
"value": "true",
"name": "Gift Wrap",
"type": "bool",
"id": "60b139053e2387000936c48e"
}
],
"id": "60b1378f33ce7300086e67bd"
},
{
"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-28T18:14:06.199Z",
"updatedAt": "2021-05-28T18:40:28.791Z",
"_id": "60b132ee41b0a000089fafdb",
"itemId": 1000000033,
"quantity": 2,
"priceListId": 100000,
"sku": "SHIRT001",
"taxCode": "TAX001",
"title": "Shirt",
"weight": 60,
"lineItemId": 2,
"attributeTotalPrice": 50,
"totalPrice": {
"currency": "USD",
"amount": 2000
},
"attributes": [
{
"price": 25,
"_id": "60b1391c3e2387000936c490",
"attributeId": "6092cba26fe410000872bc62",
"value": "true",
"name": "Gift Wrap",
"type": "bool",
"id": "60b1391c3e2387000936c490"
}
],
"id": "60b132ee41b0a000089fafdb"
}
],
"allPromosApplied": [],
"attributes": [],
"createdAt": "2021-05-28T18:14:06.542Z",
"updatedAt": "2021-05-28T18:40:28.804Z",
"__v": 0,
"totalAmount": {
"currency": "USD",
"amount": 4100
},
"quantity": 4,
"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