XM
Powered By GitBook
Merge Guest Cart with Logged-in User Cart
Path:
1
PATCH https://{baseurl}/api-cart/cart/merge
Copied!
Users may add items to cart as a guest user or a logged in user. Using this API, the cart created from a guest account is merged with the cart created from a logged in account. If an identical item exits in both the carts, the quantity is appended as 2 in the merged cart.
Note: The guest cart is not persisted.

Headers

Content-Type : application/json
Authorization: The JWT Authorization toke from the Login API.
x-site-context : { "date": "2020-08-28T02:35:27.787Z", "channel": 12, "account": 5f493c9f30ec2a0007a94fc8", "stage": "sandbox" }

Parameters

Type : requestBody
Name : The guestCartId from the response of Add Items to Cart (as guest) API.
Required: true

Sample Request

Path:
1
PATCH https://{baseurl}/api-cart/cart/merge
Copied!
Request Body:
1
{
2
"guestCartId": "5e99d75cfcef0314e06b64b8"
3
}
Copied!

Response

Success Code: 200
Description: You'll see this message when the promo is successfully applied.
1
{
2
"_id": "5e99d75cfcef0314e06b64b8",
3
"deleted": false,
4
"allPromosApplied": [],
5
"cartId": 355,
6
"items": [
7
{
8
"price": {
9
"discount": {
10
"promosApplied": [],
11
"price": 0
12
},
13
"validate": true,
14
"sale": 0,
15
"base": 260,
16
"currency": "USD"
17
},
18
"group": [
19
"5ddd1a156c5a5fed1e0d91fb"
20
],
21
"createdAt": "2020-04-17T01:02:12.054Z",
22
"updatedAt": "2020-04-17T16:21:53.057Z",
23
"_id": "5e99d75cfcef0314e06b64b9",
24
"itemId": 1000000012,
25
"quantity": 2,
26
"sku": "1554369",
27
"taxCode": "PH060771",
28
"lineItemId": 1,
29
"totalPrice": {
30
"currency": "USD",
31
"amount": 520
32
},
33
"id": "5e99d75cfcef0314e06b64b9"
34
},
35
{
36
"price": {
37
"discount": {
38
"promosApplied": [],
39
"price": 0
40
},
41
"validate": true,
42
"sale": 0,
43
"base": 380,
44
"currency": "USD"
45
},
46
"group": [
47
"5ddd1a156c5a5fed1e0d91fb"
48
],
49
"createdAt": "2020-04-17T01:02:12.054Z",
50
"updatedAt": "2020-04-17T16:21:53.082Z",
51
"_id": "5e99d75cfcef0314e06b64ba",
52
"itemId": 1000000014,
53
"quantity": 2,
54
"sku": "1539213",
55
"taxCode": "PH060771",
56
"lineItemId": 2,
57
"totalPrice": {
58
"currency": "USD",
59
"amount": 760
60
},
61
"id": "5e99d75cfcef0314e06b64ba"
62
},
63
{
64
"price": {
65
"discount": {
66
"promosApplied": [],
67
"price": 0
68
},
69
"validate": true,
70
"sale": 0,
71
"base": 260,
72
"currency": "USD"
73
},
74
"group": [
75
"5ddd1a156c5a5fed1e0d91fb"
76
],
77
"createdAt": "2020-04-17T01:02:12.054Z",
78
"updatedAt": "2020-04-17T16:21:53.104Z",
79
"_id": "5e99d6e2fcef0314e06b64b2",
80
"itemId": 1000000012,
81
"quantity": 2,
82
"sku": "1554369",
83
"taxCode": "PH060771",
84
"lineItemId": 3,
85
"totalPrice": {
86
"currency": "USD",
87
"amount": 520
88
},
89
"id": "5e99d6e2fcef0314e06b64b2"
90
},
91
{
92
"price": {
93
"discount": {
94
"promosApplied": [],
95
"price": 0
96
},
97
"validate": true,
98
"sale": 0,
99
"base": 380,
100
"currency": "USD"
101
},
102
"group": [
103
"5ddd1a156c5a5fed1e0d91fb"
104
],
105
"createdAt": "2020-04-17T01:02:12.054Z",
106
"updatedAt": "2020-04-17T16:21:53.127Z",
107
"_id": "5e99d6e2fcef0314e06b64b3",
108
"itemId": 1000000014,
109
"quantity": 2,
110
"sku": "1539213",
111
"taxCode": "PH060771",
112
"lineItemId": 4,
113
"totalPrice": {
114
"currency": "USD",
115
"amount": 760
116
},
117
"id": "5e99d6e2fcef0314e06b64b3"
118
}
119
],
120
"userId": "5e97947d3cb8553c0e43d87f",
121
"createdAt": "2020-04-17T16:20:44.093Z",
122
"updatedAt": "2020-04-17T16:21:53.131Z",
123
"__v": 0,
124
"totalAmount": {
125
"currency": "USD",
126
"amount": 2560
127
},
128
"quantity": 8,
129
"errors": {
130
"inventory": [],
131
"price": []
132
}
133
}
Copied!
Error Code: 404
Message: Not found
Description: You will see this error when the carts couldn't be merged due one or both carts doesn't exist in the system.
1
{
2
"code": "CART_NOT_FOUND",
3
"message": "Cart not found."
4
}
Copied!
Response Code: 400
Message: Request validation
Description: You will see this error when cart ID is lesser or greater than 24 characters.
1
{
2
"code": "REQUEST_VALIDATION",
3
"message": "Invalid data in path: /cartId should NOT be shorter than 24 characters"
4
}
Copied!
Response Code: 401
Message: Unauthorized
Description: You will see this error when the authorization token is invalid.
1
{
2
"message": "Unauthorized"
3
}
Copied!
Response Code: 500
Message: Internal Server Error
Description: You will see this when there is an Account ID mismatch with the cart ID.
1
{
2
"message": "accountid is required for @teamfabric/request module."
3
}
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 2mo ago
Copy link
Contents
Change Log