XM
Powered By GitBook
Add Items to Cart
Path:
1
POST /cart-decoupled/item
Copied!
This API enables your customers to add new items to their digital cart. With the first item in the cart, a unique cartId is generated, to be used for the subsequent calls. In response, this endpoint retrieves the details of individual items in the cart such as pricing, quantity, weight, taxCode, unit of measure, created & updated time stamp, etc. along with the applicable promotional codes.
Note: userAuthToken is required only for logged in user (not applicable for guest user).
Headers
x-site-context : { "date": "2020-08-28T02:35:27.787Z", "channel": 12, "account": 5f493c9f30ec2a0007a94fc8", "stage": "sandbox" }

Parameters

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

Sample Request - Add item to cart as guest user

The use case is a guess user adding item to the cart. Hence, userAuthToken is null. For a logged in user, userAuthToken must be specified. In the response for the logged in user, userID is additionally included.
1
{
2
"cartId": null,
3
"userAuthToken": null,
4
"registeredUser": false,
5
"items": [
6
{
7
"itemId": {{itemId}},
8
"sku": "{{sku}}",
9
"taxCode": "{{taxCode}}",
10
"title": "{{title}}",
11
"weight": {{weight}},
12
"quantity": 2,
13
"group": [
14
"{{groupId}}"
15
],
16
"price": {
17
"sale": null,
18
"base": 19,
19
"discount": {
20
"price": 0,
21
"discountAmount": 0,
22
"promosApplied": []
23
},
24
"currency": "USD"
25
},
26
"extra": {}
27
}
28
]
29
}
Copied!

Sample Response

Response Code: 200
Message: OK
1
{
2
"_id": "60803ceb630ef900087e2f4d",
3
"deleted": false,
4
"registeredUser": false,
5
"cartId": 1485,
6
"items": [
7
{
8
"price": {
9
"discount": {
10
"discountAmount": 0,
11
"price": 0,
12
"promosApplied": []
13
},
14
"sale": 0,
15
"base": 19,
16
"currency": "USD"
17
},
18
"sample": false,
19
"discountedQuantity": 0,
20
"group": [
21
"5ecef789df21ae00077e7a2f"
22
],
23
"weightUnit": "lb",
24
"isPickup": false,
25
"createdAt": "2021-04-21T14:54:05.290Z",
26
"updatedAt": "2021-04-21T14:54:05.290Z",
27
"_id": "60803ceb630ef900087e2f4e",
28
"itemId": 1000000167,
29
"sku": "sk231212",
30
"taxCode": "TC1234567890",
31
"title": "fabric t-shirt",
32
"weight": 4.2,
33
"quantity": 2,
34
"lineItemId": 1,
35
"attributeTotalPrice": 0,
36
"totalPrice": {
37
"currency": "USD",
38
"amount": 38
39
},
40
"attributes": [],
41
"id": "60803ceb630ef900087e2f4e"
42
}
43
],
44
"allPromosApplied": [],
45
"attributes": [],
46
"createdAt": "2021-04-21T14:55:39.408Z",
47
"updatedAt": "2021-04-21T14:55:39.413Z",
48
"__v": 0,
49
"totalAmount": {
50
"currency": "USD",
51
"amount": 38
52
},
53
"quantity": 2
54
}
Copied!

Sample Request - Add item to existing cart as guest user

The use case is a guess user adding item to an existing cart. Here, userAuthToken is null. For a logged in user, userAuthToken must be specified. In the response for the logged in user, userID is additionally included.
1
{
2
"cartId": "5f5be88ea99a54da8f13524a",
3
"userAuthToken": null,
4
"registeredUser": true,
5
"userId": "5f5be636b7b41c2288f8e76b",
6
"items": [
7
{
8
"itemId": {{itemId}},
9
"sku": "{{sku}}",
10
"taxCode": "{{taxCode}}",
11
"title": "{{title}}",
12
"weight": {{weight}},
13
"quantity": 2,
14
"group": [
15
"{{groupId}}"
16
],
17
"price": {
18
"sale": null,
19
"base": 19,
20
"discount": {
21
"price": 0,
22
"discountAmount": 0,
23
"promosApplied": []
24
},
25
"currency": "USD"
26
},
27
"extra": {}
28
}
29
]
30
}
Copied!

Sample Response

Response Code: 200
Message: OK
1
{
2
"_id": "60803d42630ef900087e2f51",
3
"deleted": false,
4
"registeredUser": true,
5
"cartId": 1486,
6
"items": [
7
{
8
"price": {
9
"discount": {
10
"discountAmount": 0,
11
"price": 0,
12
"promosApplied": []
13
},
14
"sale": 0,
15
"base": 19,
16
"currency": "USD"
17
},
18
"sample": false,
19
"discountedQuantity": 0,
20
"group": [
21
"5ecef789df21ae00077e7a2f"
22
],
23
"weightUnit": "lb",
24
"isPickup": false,
25
"createdAt": "2021-04-21T14:54:05.290Z",
26
"updatedAt": "2021-04-21T14:54:05.290Z",
27
"_id": "60803d42630ef900087e2f52",
28
"itemId": 1000000167,
29
"sku": "sk231212",
30
"taxCode": "TC1234567890",
31
"title": "fabric t-shirt",
32
"weight": 4.2,
33
"quantity": 2,
34
"lineItemId": 1,
35
"attributeTotalPrice": 0,
36
"totalPrice": {
37
"currency": "USD",
38
"amount": 38
39
},
40
"attributes": [],
41
"id": "60803d42630ef900087e2f52"
42
}
43
],
44
"allPromosApplied": [],
45
"attributes": [],
46
"createdAt": "2021-04-21T14:57:06.378Z",
47
"updatedAt": "2021-04-21T14:57:06.385Z",
48
"__v": 0,
49
"totalAmount": {
50
"currency": "USD",
51
"amount": 38
52
},
53
"quantity": 2
54
}
Copied!

Sample Request - Add item to existing cart as guest user, with promo

The use case is a guess user adding item to an existing cart, with promo. Here, userAuthToken is null. For a logged in user, userAuthToken must be specified. In the response for the logged in user, userID is additionally included.
1
{
2
"cartId": null,
3
"userAuthToken": null,
4
"registeredUser": false,
5
"items": [
6
{
7
"itemId": {{itemId}},
8
"sku": "{{sku}}",
9
"taxCode": "{{taxCode}}",
10
"title": "{{title}}",
11
"weight": {{weight}},
12
"quantity": 2,
13
"group": [
14
"{{groupId}}"
15
],
16
"price": {
17
"sale": null,
18
"base": 19,
19
"discount": {
20
"price": 260,
21
"promosApplied": [
22
{
23
"unit": "%OFF",
24
"value": 10,
25
"ON": {
26
"kind": "SKU",
27
"value": null
28
},
29
"promoId": "5eba961dd5c898000811586f",
30
"promoCode": "TEST20"
31
}
32
]
33
},
34
"currency": "USD"
35
},
36
"extra": {}
37
}
38
]
39
}
Copied!

Sample Response

Response Code: 200
Message: OK
1
{
2
"_id": "60803de3630ef900087e2f5d",
3
"deleted": false,
4
"registeredUser": false,
5
"cartId": 1487,
6
"items": [
7
{
8
"price": {
9
"discount": {
10
"discountAmount": 0,
11
"price": 260,
12
"promosApplied": [
13
{
14
"unit": "%OFF",
15
"value": 10,
16
"ON": {
17
"kind": "SKU",
18
"value": null
19
},
20
"promoId": "5eba961dd5c898000811586f",
21
"promoCode": "TEST20"
22
}
23
]
24
},
25
"sale": 0,
26
"base": 19,
27
"currency": "USD"
28
},
29
"sample": false,
30
"discountedQuantity": 0,
31
"group": [
32
"5ecef789df21ae00077e7a2f"
33
],
34
"weightUnit": "lb",
35
"isPickup": false,
36
"createdAt": "2021-04-21T14:54:05.290Z",
37
"updatedAt": "2021-04-21T14:54:05.290Z",
38
"_id": "60803de3630ef900087e2f5e",
39
"itemId": 1000000167,
40
"sku": "sk231212",
41
"taxCode": "TC1234567890",
42
"title": "fabric t-shirt",
43
"weight": 4.2,
44
"quantity": 2,
45
"lineItemId": 1,
46
"attributeTotalPrice": 0,
47
"totalPrice": {
48
"currency": "USD",
49
"amount": 38
50
},
51
"attributes": [],
52
"id": "60803de3630ef900087e2f5e"
53
}
54
],
55
"allPromosApplied": [],
56
"attributes": [],
57
"createdAt": "2021-04-21T14:59:47.528Z",
58
"updatedAt": "2021-04-21T14:59:47.536Z",
59
"__v": 0,
60
"totalAmount": {
61
"currency": "USD",
62
"amount": 38
63
},
64
"quantity": 2
65
}
Copied!
Response Code: 400
Message: Bad Request - Missing Required Attribute
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 2mo ago
Copy link
Contents
Change Log