XM

Apply Promo

Path:

PATCH https://{baseurl}/api-cart/cart/apply-promo

Shoppers find good deals hard to resist; discovering and availing deals give them an enhanced shopping experience. This API enables your customers to easily add promotional code to their cart, at any stage before billing.

Headers

Content-Type : application/json

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

Parameters

Type : requestBody

Name : The 24 character system-generated cart ID (from the Add Items to Cart or Retrieve Cart by Authorization Token API) and the promoName.

Required: true

Sample Request

path:

PATCH https://{baseurl}/api-cart/cart/apply-promo

Request Body

{
"cartId": "607f8a8f0118960009a8e6ee",
"promoName": "custdash"
}

Sample Response

Success Code: 200

Message: OK

Description: You'll see this message when the promo is successfully applied.

{
"_id": "607f8a8f0118960009a8e6ee",
"deleted": false,
"registeredUser": true,
"cartId": 1475,
"items": [
{
"price": {
"discount": {
"discountAmount": 450,
"price": 450,
"promosApplied": [
{
"unit": "%OFF",
"value": 50,
"ON": {
"kind": "SKU",
"value": null
},
"id": "6063ed0158d627000720d39d",
"promoId": "605b821da953e9000759f735",
"promoCode": "custdash"
}
]
},
"sale": 0,
"base": 900,
"currency": "USD"
},
"sample": false,
"discountedQuantity": 4,
"group": [
"123123123123123213212222"
],
"weightUnit": "lb",
"isPickup": false,
"createdAt": "2021-04-21T02:14:38.620Z",
"updatedAt": "2021-04-21T18:44:41.712Z",
"_id": "607f8a8f0118960009a8e6ef",
"itemId": 1000000051,
"quantity": 4,
"priceListId": 100269,
"sku": "1538910",
"taxCode": "PH060771",
"title": "Luminous Cushion Lagoon",
"weight": 1,
"lineItemId": 1,
"attributeTotalPrice": 0,
"totalPrice": {
"currency": "USD",
"amount": 1800
},
"attributes": [],
"id": "607f8a8f0118960009a8e6ef"
},
{
"price": {
"discount": {
"discountAmount": 0,
"price": 0,
"promosApplied": []
},
"sale": 48,
"base": 148,
"currency": "USD"
},
"sample": false,
"discountedQuantity": 0,
"group": [
"123123123123123213212222"
],
"weightUnit": "lb",
"isPickup": false,
"createdAt": "2021-04-21T02:14:38.620Z",
"updatedAt": "2021-04-21T18:44:41.713Z",
"_id": "607f8a8f0118960009a8e6f0",
"itemId": 1000000052,
"quantity": 2,
"priceListId": 100269,
"sku": "1583908",
"taxCode": "PH060771",
"title": "Embellished Pillow Pink",
"weight": 1,
"lineItemId": 2,
"attributeTotalPrice": 0,
"totalPrice": {
"currency": "USD",
"amount": 96
},
"attributes": [],
"id": "607f8a8f0118960009a8e6f0"
}
],
"userId": "600a56593245200007982fac",
"allPromosApplied": [
{
"promoId": "605b821da953e9000759f735",
"promoCode": "custdash"
}
],
"attributes": [],
"createdAt": "2021-04-21T02:14:39.048Z",
"updatedAt": "2021-04-21T18:44:41.759Z",
"__v": 0,
"totalAmount": {
"currency": "USD",
"amount": 1896
},
"quantity": 6,
"errors": {
"inventory": [],
"price": [],
"promo": [
{
"promoChange": true
}
]
}
}

Error Code: 400

Message: Bad request

Description: You will see this error when the promo is already applied.

{
"code": "PROMO_ALREADY_APPLIED",
"message": "custdash has already been applied."
}

Response Code: 404

Message: Not Found - Promo not found

Description: You will see this when promo doesn't exist in the system.

{
"code": "PROMO_NOT_FOUND",
"message": "The promo code you entered doesn’t exist."
}

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