XM

Merge Guest and User Carts

Path:

PATCH /cart/merge

User 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 added to 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

Authorization: JWT

x-site-context : { "date": "2020-08-28T02:35:27.787Z", "channel": 12, "account": 5f493c9f30ec2a0007a94fc8", "stage": "sandbox" }

Consumes

  • application/json

Produces

  • application/json

Parameters

Type: body

Name: guestCartId

Required: true

Sample Request

{
"guestCartId": "5e99d6e2fcef0314e06b64b1"
}

Response

Response Code: 200

{
"_id": "5e99d75cfcef0314e06b64b8",
"deleted": false,
"allPromosApplied": [],
"cartId": 355,
"items": [
{
"price": {
"discount": {
"promosApplied": [],
"price": 0
},
"validate": true,
"sale": 0,
"base": 260,
"currency": "USD"
},
"group": [
"5ddd1a156c5a5fed1e0d91fb"
],
"createdAt": "2020-04-17T01:02:12.054Z",
"updatedAt": "2020-04-17T16:21:53.057Z",
"_id": "5e99d75cfcef0314e06b64b9",
"itemId": 1000000012,
"quantity": 2,
"sku": "1554369",
"taxCode": "PH060771",
"lineItemId": 1,
"totalPrice": {
"currency": "USD",
"amount": 520
},
"id": "5e99d75cfcef0314e06b64b9"
},
{
"price": {
"discount": {
"promosApplied": [],
"price": 0
},
"validate": true,
"sale": 0,
"base": 380,
"currency": "USD"
},
"group": [
"5ddd1a156c5a5fed1e0d91fb"
],
"createdAt": "2020-04-17T01:02:12.054Z",
"updatedAt": "2020-04-17T16:21:53.082Z",
"_id": "5e99d75cfcef0314e06b64ba",
"itemId": 1000000014,
"quantity": 2,
"sku": "1539213",
"taxCode": "PH060771",
"lineItemId": 2,
"totalPrice": {
"currency": "USD",
"amount": 760
},
"id": "5e99d75cfcef0314e06b64ba"
},
{
"price": {
"discount": {
"promosApplied": [],
"price": 0
},
"validate": true,
"sale": 0,
"base": 260,
"currency": "USD"
},
"group": [
"5ddd1a156c5a5fed1e0d91fb"
],
"createdAt": "2020-04-17T01:02:12.054Z",
"updatedAt": "2020-04-17T16:21:53.104Z",
"_id": "5e99d6e2fcef0314e06b64b2",
"itemId": 1000000012,
"quantity": 2,
"sku": "1554369",
"taxCode": "PH060771",
"lineItemId": 3,
"totalPrice": {
"currency": "USD",
"amount": 520
},
"id": "5e99d6e2fcef0314e06b64b2"
},
{
"price": {
"discount": {
"promosApplied": [],
"price": 0
},
"validate": true,
"sale": 0,
"base": 380,
"currency": "USD"
},
"group": [
"5ddd1a156c5a5fed1e0d91fb"
],
"createdAt": "2020-04-17T01:02:12.054Z",
"updatedAt": "2020-04-17T16:21:53.127Z",
"_id": "5e99d6e2fcef0314e06b64b3",
"itemId": 1000000014,
"quantity": 2,
"sku": "1539213",
"taxCode": "PH060771",
"lineItemId": 4,
"totalPrice": {
"currency": "USD",
"amount": 760
},
"id": "5e99d6e2fcef0314e06b64b3"
}
],
"userId": "5e97947d3cb8553c0e43d87f",
"createdAt": "2020-04-17T16:20:44.093Z",
"updatedAt": "2020-04-17T16:21:53.131Z",
"__v": 0,
"totalAmount": {
"currency": "USD",
"amount": 2560
},
"quantity": 8,
"errors": {
"inventory": [],
"price": []
}
}

Response Code: 404

Message: Cart Not Found

Changelog

  • April-2021 last updated