XM
Members
Add Items to Cart
This documentation is now outdated, please find the latest docs for this endpoint here
Path:
1
POST https://{baseurl}/api-cart/cart/item
Copied!
Enables your customers to add new items to their digital cart and also increment the item quantity in an existing cart (However, to decrement the item quantity, the Update Cart API is recommended.) With the first item in the cart, a unique cart ID (represented as _id) is generated. This cart ID (represented as _id in the response) is required for the subsequent calls.
Note: A maximum of 500 items can be added to a cart. Headers
Content-Type : application/json
x-site-context : { "date": "2020-08-28T02:35:27.787Z", "channel": 12, "account": 5f493c9f30ec2a0007a94fc8", "stage": "sandbox" }
Authorization: The JWT access token from the Login API. This is applicable only for a logged in user (not for guest user).

Parameters

Type : requestBody
Name : The items to be added to the cart.
Required: true

Sample Request - Add Item To Cart as a Guest user

Path:
1
POST https://{baseurl}/api-cart/cart/item
Copied!
Request Body:
For a logged in user, Authorization (JWT token from the Login API) must be specified in the header. It is not required for a guest user.
1
{
2
"cartId":null,
3
"items": [
4
{
5
"itemId": 170,
6
"quantity": 1,
7
"group": [
8
"123123123123123213212222"
9
],
10
"price": {
11
"sale": 0,
12
"base": 0,
13
"discount": {
14
"price": 0,
15
"discountAmount": 0,
16
"promosApplied": []
17
},
18
"currency": "USD"
19
},
20
"extra": {}
21
}
22
]
23
}
Copied!

Sample Response - Guest user

Success Code: 200
Message: OK
Description: You will see this message when items selected are successfully added to the guest cart. In the response for a logged in user, an additional field 'userID' is included (userId is not applicable for a guest user.)
1
{
2
"_id": "60e356acc8bcd300099e66a8",
3
"deleted": false,
4
"registeredUser": false,
5
"cartId": 785,
6
"items": [
7
{
8
"price": {
9
"discount": {
10
"discountAmount": 0,
11
"price": 0,
12
"promosApplied": []
13
},
14
"sale": 0,
15
"base": 100,
16
"currency": "USD"
17
},
18
"sample": false,
19
"discountedQuantity": 0,
20
"group": [
21
"123123123123123213212222"
22
],
23
"weightUnit": "lb",
24
"isPickup": false,
25
"createdAt": "2021-07-05T18:59:18.717Z",
26
"updatedAt": "2021-07-05T18:59:57.700Z",
27
"_id": "60e356acc8bcd300099e66a9",
28
"itemId": 170,
29
"quantity": 1,
30
"priceListId": 100000,
31
"sku": "testPrice",
32
"taxCode": "EWPE",
33
"title": "Pricing",
34
"weight": 23,
35
"lineItemId": 1,
36
"attributeTotalPrice": 0,
37
"totalPrice": {
38
"currency": "USD",
39
"amount": 100
40
},
41
"attributes": [],
42
"id": "60e356acc8bcd300099e66a9"
43
}
44
],
45
"allPromosApplied": [],
46
"attributes": [],
47
"createdAt": "2021-07-05T18:59:56.836Z",
48
"updatedAt": "2021-07-05T18:59:57.715Z",
49
"__v": 0,
50
"totalAmount": {
51
"currency": "USD",
52
"amount": 100
53
},
54
"quantity": 1,
55
"errors": {
56
"inventory": [],
57
"price": [
58
{
59
"_id": "60c0f38f4fa92c0008dfd0d5",
60
"isSoftDeleted": false,
61
"priceListId": 100000,
62
"itemId": 170,
63
"offers": [
64
{
65
"price": {
66
"sale": 0,
67
"cost": 90,
68
"currency": "USD",
69
"base": 100,
70
"discount": {
71
"discountAmount": 0,
72
"price": 0,
73
"promosApplied": []
74
}
75
},
76
"_id": "60c0f38f4fa92c0008dfd0d6",
77
"kind": null,
78
"channel": 12,
79
"startDate": "2021-06-09T17:15:00.000Z",
80
"endDate": "2100-01-01T07:59:00.000Z",
81
"offerCode": 1005,
82
"range": []
83
}
84
]
85
}
86
],
87
"promo": []
88
}
89
}
Copied!

Sample Response - Logged in User

Success Code: 200
Message: OK
Description: You will see this message when items selected are successfully added to the cart of a logged in user. In the response for a logged in user, an additional field 'userID' is included (userId is not applicable for a guest user.)
1
{
2
"_id": "60e35687c8bcd300099e66a6",
3
"deleted": false,
4
"registeredUser": true,
5
"cartId": 784,
6
"items": [
7
{
8
"price": {
9
"discount": {
10
"discountAmount": 0,
11
"price": 0,
12
"promosApplied": []
13
},
14
"sale": 0,
15
"base": 100,
16
"currency": "USD"
17
},
18
"sample": false,
19
"discountedQuantity": 0,
20
"group": [
21
"123123123123123213212222"
22
],
23
"weightUnit": "lb",
24
"isPickup": false,
25
"createdAt": "2021-07-05T18:59:18.717Z",
26
"updatedAt": "2021-07-05T18:59:23.350Z",
27
"_id": "60e35687c8bcd300099e66a7",
28
"itemId": 170,
29
"quantity": 1,
30
"priceListId": 100000,
31
"sku": "testPrice",
32
"taxCode": "EWPE",
33
"title": "Pricing",
34
"weight": 23,
35
"lineItemId": 1,
36
"attributeTotalPrice": 0,
37
"totalPrice": {
38
"currency": "USD",
39
"amount": 100
40
},
41
"attributes": [],
42
"id": "60e35687c8bcd300099e66a7"
43
}
44
],
45
"userId": "60e3565edb216f0008b538d4",
46
"allPromosApplied": [],
47
"attributes": [],
48
"createdAt": "2021-07-05T18:59:19.095Z",
49
"updatedAt": "2021-07-05T18:59:23.361Z",
50
"__v": 0,
51
"totalAmount": {
52
"currency": "USD",
53
"amount": 100
54
},
55
"quantity": 1,
56
"errors": {
57
"inventory": [],
58
"price": [
59
{
60
"_id": "60c0f38f4fa92c0008dfd0d5",
61
"isSoftDeleted": false,
62
"priceListId": 100000,
63
"itemId": 170,
64
"offers": [
65
{
66
"price": {
67
"sale": 0,
68
"cost": 90,
69
"currency": "USD",
70
"base": 100,
71
"discount": {
72
"discountAmount": 0,
73
"price": 0,
74
"promosApplied": []
75
}
76
},
77
"_id": "60c0f38f4fa92c0008dfd0d6",
78
"kind": null,
79
"channel": 12,
80
"startDate": "2021-06-09T17:15:00.000Z",
81
"endDate": "2100-01-01T07:59:00.000Z",
82
"offerCode": 1005,
83
"range": []
84
}
85
]
86
}
87
],
88
"promo": []
89
}
90
}
Copied!
Error Code: 404
Message: Item not in stock
Description: You will see this error when the specified item is not in stock.
1
{
2
"code": "NOT_IN_STOCK",
3
"message": "ItemIds 1000000038 are not in stock."
4
}
Copied!
Error Code: 404
Message: Not Found
Description: You will see this error when the item or price list ID is not found.
1
{
2
"code": "PRICE_LIST_ITEM_ID_NOT_FOUND",
3
"message": "ItemIds, PriceListIds [1000000052, 100268] not found."
4
}
Copied!
Error Code: 404
Message: Not found
Description: You will see this error when Weight or tax code is not found.
1
{
2
"code": "ATTRIBUTE_CODE_NOT_FOUND",
3
"message": "attribute Weight not found for itemId 91."
4
}
Copied!
Error Code: 401
Message: Unauthorized
Description: You will see this error when the Authorization (JWT token from the Login APIs) is not valid.
1
{
2
"code": "INVALID_AUTHORIZATION_TOKEN",
3
"message": "Invalid Authorization Token"
4
}
Copied!
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
Last modified 1mo ago
Copy link
Contents
Change Log