XM

Add Shipping to Line Items

Path:

PATCH https://{baseurl}/api-cart/cart/{cartId}/ship-to

Users may have the requirement to ship items in the cart to multiple locations. This API facilitates adding shipping details for each line item in the cart. Fabric also supports rules to set up international shipping methods.

Note: Postal address is required only for physical items; for digital items, email address would suffice.

Headers

Content-Type : application/json

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

Parameters

Type : path

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

Required: true

Type: requestBody

Name: The shipping details.

Required: true

Sample Request

Path:

https://{baseurl}/api-cart/cart/5e99d75cfcef0314e06b64b8/ship-to

Request Body:

[
{
"itemId": 1000000012,
"lineItemId": 1,
"shipToId": "5e99dd58fcef0314e06b64fe"
},
{
"itemId": 1000000014,
"lineItemId": 2,
"shipToId": "5e99dd58fcef0314e06b64fe"
},
{
"itemId": 1000000012,
"lineItemId": 3,
"shipToId": "5e99dd58fcef0314e06b64fe"
},
{
"itemId": 1000000014,
"lineItemId": 4,
"shipToId": "5e99dd58fcef0314e06b64fe"
}
]
‚Äč

Response

Success Code: 200

Message: OK

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

{
"_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:33:21.191Z",
"_id": "5e99d75cfcef0314e06b64b9",
"itemId": 1000000012,
"quantity": 15,
"sku": "1554369",
"taxCode": "PH060771",
"lineItemId": 1,
"totalPrice": {
"currency": "USD",
"amount": 3900
},
"shipTo": "5e99dd58fcef0314e06b64fe",
"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:33:21.212Z",
"_id": "5e99d75cfcef0314e06b64ba",
"itemId": 1000000014,
"quantity": 15,
"sku": "1539213",
"taxCode": "PH060771",
"lineItemId": 2,
"totalPrice": {
"currency": "USD",
"amount": 5700
},
"shipTo": "5e99dd58fcef0314e06b64fe",
"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:33:21.231Z",
"_id": "5e99d6e2fcef0314e06b64b2",
"itemId": 1000000012,
"quantity": 2,
"sku": "1554369",
"taxCode": "PH060771",
"lineItemId": 3,
"totalPrice": {
"currency": "USD",
"amount": 520
},
"shipTo": "5e99dd58fcef0314e06b64fe",
"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:33:21.249Z",
"_id": "5e99d6e2fcef0314e06b64b3",
"itemId": 1000000014,
"quantity": 2,
"sku": "1539213",
"taxCode": "PH060771",
"lineItemId": 4,
"totalPrice": {
"currency": "USD",
"amount": 760
},
"shipTo": "5e99dd58fcef0314e06b64fe",
"id": "5e99d6e2fcef0314e06b64b3"
}
],
"userId": "5e97947d3cb8553c0e43d87f",
"createdAt": "2020-04-17T16:20:44.093Z",
"updatedAt": "2020-04-17T17:06:03.833Z",
"__v": 0,
"totalAmount": {
"currency": "USD",
"amount": 10880
},
"quantity": 34
}

Error Code: 404

Message: Not found

Description: You will see this error when the specified cart ID doesn't exist in the system.

{
"code": "CART_NOT_FOUND",
"message": "Cart not found."
}

Error Code: 400

Message: Request validation

Description: You will see this error when the specified cart ID is lesser or greater than 24 characters.

{
"code": "REQUEST_VALIDATION",
"message": "Invalid data in path: /cartId should NOT be shorter than 24 characters"
}

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