docs
  1. SCAYLE Resource Center
  2. Developer Guides
  3. Basket & Wishlist
  4. Basket

Basket

General

Customers must place items in the basket before proceeding to the checkout and completing a purchase. Included products can be reviewed, edited, or moved to the customer's wish list at any point in time.

Products in the basket always include the respective variant since this is the entity to be sold. So, whether you are adding, updating, or deleting items, you deal with the individual variant and its availability – without exception.

The products are kept for 60 days in the basket and this time is reset in case any change is made within the basket entity. After this period, the products are deleted from the basket.

Promotions at the item level within the basket are always included if a promotionId is present. However, the validity of the promotion (promotion.isValid) and any failed conditions (promotion.failedConditions) depends on whether the promotion meets its specified conditions. If the conditions are met, isValid is true, and failedConditions is an empty array; otherwise, it could be vice versa. If there is no promotionId, both promotionId and the promotion object will be null at the basket item level.

Retrieve a list of all applicable promotions by including the ?with=applicablePromotions query parameter. To display applicable promotions, submit a basket item without the "promotionId" parameter. If the "promotionId" is included, the promotion becomes directly associated with the item, and no other applicable promotions will be displayed.

For example, to get basket items with applicable promotions: GET /v1/baskets/{basket_key}?with=applicablePromotions

You need a configured Storefront API client to:

  • get basket items
  • get basket items with applicable promotions
  • add items to the basket
  • add items to the basket with promotionId
  • add items to the basket with promotionCode
  • update items in the basket
  • update basket item with promotionId
  • update basket item with promotionCode
  • remove item from the basket

Storefront API

When selling products, remember that you are always working with its respective variants.

The number of items you can add to the basket depends on how many product variants are in stock.

If you add a number higher than what is in stock, the system will automatically add the maximum number of what is available. If a product is not available at all, the request will fail. If the variant was added before it was unavailable, it will be flagged as sold out.

Item quantity

You cannot add an item, which is already in the basket. In this case, you need to update the quantity.

Add basket item

We are going to add our first product variant to the basket of a customer. In this example it is about customer 1234 who wants 3 pieces of a specific shirt with variant ID 1.

Each basket has a specific key which we can freely come up with. Here we can use the pattern myshop_customer_$customerId. Whenever we want to work with this basket, we need to refer to that specific key. We also request some product and variant related information, e.g. product name and variant sizes.

Use addOrUpdateItem()

The NodeJS SDK provides the method addOrUpdateItem() which works similar to addItem() but can be run again for the same variant with an updated quantity. If you run addItem() for a variant which exists in the basket it results in a failure.

For PHP and Java use update() to change quantity.

ParameterTypeRequiredDescription
basketKeystringtrueKey of the basket.
variantIdintegertrueID of the variant to be added to the basket.
quantityintegertrueQuantity of variants to be added to the basket.
promotionIdstringfalseID of promotion to be added to the basket.
promotionCodestringfalseCode of promotion to be added to the basket.
withobjectfalseDefines which optional fields should be included in the response. Contained as with inside the options object (fourth parameter).
customDatastringfalse

For each item, you can add an additional custom data array. The data will remain attached to the basket item and you may retrieve it at any time during or after the checkout and order process.

You can specify pricePromotionKey here as well to adjust variant price based on a promotion. If the variant does not have a matching price promotion, the default price is returned.

// Add variant with id 1 to our customer's basket
const response = await client.basket.addItem( // or addOrUpdateItem()
  "myshop_customer_1234",
  1, // variantId
  3, // quantity
  {
    with: {
      items: {
        variant: {
          attributes: "all",
        },
        product: {
          attributes: { withKey: ["name"] },
        },
      },
    },
  }
);
const item = response.basket.items[0];

console.log(item.product.attributes.name.values.label);
console.log(`Size: ${item.variant.attributes.size.values.label}`);
console.log(`Quantity: ${item.quantity}`);
// Hilfiger Shirt
// Size: S
// Quantity: 3
Response
{
  "type": "success",
  "basket": {
    "key": "myshop_customer_1234",
    "items": [
      {
        "key": "c4ca4238a0b923820dcc509a6f75849b",
        "packageId": 1,
        "quantity": 3,
        "status": "available",
        "displayData": {},
        "availableQuantity": 31,
        "deliveryForecast": {},
        "customData": {},
        "lowestPriorPrice": {
          "withTax": null,
          "relativeDifferenceToPrice": null
        },
        "price": {
          "total": {
            "currencyCode": "EUR",
            "withTax": 11970,
            "withoutTax": 10059,
            "recommendedRetailPrice": null,
            "tax": { "vat": { "amount": 1911, "rate": 0 } },
            "appliedReductions": []
          },
          "unit": {
            "currencyCode": "EUR",
            "withTax": 3990,
            "withoutTax": 3353,
            "recommendedRetailPrice": null,
            "tax": { "vat": { "amount": 637, "rate": 0 } },
            "appliedReductions": []
          }
        },
        "variant": {
          "id": 1,
          "referenceKey": "THS0906008000001_S",
          "attributes": {
            "size": {
              "id": 1002,
              "key": "size",
              "label": "Size",
              "type": "",
              "multiSelect": false,
              "values": { "id": 28, "label": "S", "value": "s" }
            }
          },
          "firstLiveAt": "0001-01-01T00:00:00+00:00",
          "createdAt": "2023-06-12T14:05:33+00:00",
          "updatedAt": "2023-07-07T11:50:06+00:00",
          "stock": {
            "supplierId": 1,
            "warehouseId": 1,
            "quantity": 31,
            "isSellableWithoutStock": false
          },
          "price": {
            "currencyCode": "EUR",
            "withTax": 3990,
            "withoutTax": 3353,
            "recommendedRetailPrice": null,
            "tax": { "vat": { "amount": 637, "rate": 0.19 } },
            "appliedReductions": []
          },
          "customData": {}
        },
        "product": {
          "id": 1,
          "isActive": true,
          "isSoldOut": false,
          "isNew": false,
          "createdAt": "2023-06-12T14:05:33+00:00",
          "updatedAt": "2023-06-12T14:05:34+00:00",
          "indexedAt": "2023-07-10T13:13:03+00:00",
          "firstLiveAt": "2023-06-12T14:05:33+00:00",
          "masterKey": "THS090600",
          "referenceKey": "THS0906008000001",
          "attributes": {
            "name": {
              "id": 20005,
              "key": "name",
              "label": "Name",
              "type": "",
              "multiSelect": false,
              "values": {
                "id": 20005,
                "label": "Hilfiger Shirt",
                "value": "name"
              }
            }
          },
          "images": [
            {
              "hash": "https://cdn.aboutstatic.com/file/cd81a5d37e4241686586812d9e179553?bg=F4F4F5&quality=75&trim=1&height=1067&width=800,https://cdn.aboutstatic.com/file/1c98f7fc408b9d2cca91abfbf5650df1?bg=F4F4F5&quality=75&height=1067&width=800, https://cdn.aboutstatic.com/f",
              "attributes": {}
            }
          ],
          "customData": {}
        },
        "itemGroup": null
        "promotionId": null
        "promotion": null
      }
    ],
    "packages": [
      {
        "carrierKey": "DEFAULT",
        "deliveryDate": { "max": "2023-07-13", "min": "2023-07-11" },
        "id": 1
      }
    ],
    "cost": {
      "currencyCode": "EUR",
      "withTax": 11970,
      "withoutTax": 10059,
      "recommendedRetailPrice": null,
      "tax": { "vat": { "amount": 1911, "rate": 0 } },
      "appliedReductions": []
    }
  }
}

Add item with promotionId

We are going to add our first product variant to the basket of a customer. In this example it is about customer 1235 who wants 2 pieces of a specific shirt with variant id 100, and promotion ID 6522f4b2b857b289b920c12e. Each basket has a specific key which we can freely come up with. Here we can with the pattern myshop_customer_$customerId. Whenever we want to work with this basket, we need to refer to that specific key. We also request some product and variant related information, e.g. product name and variant sizes.

Use addOrUpdateItem()

The NodeJS SDK provides the method addOrUpdateItem() which works similar to addItem() but can be run again for the same variant with an updated quantity. If you run addItem() for a variant which exists in the basket it results in a failure.

For PHP and Java use update() to change quantity.

// Add variant with id 100 to our customer's basket
const response = await client.basket.addItem( // or addOrUpdateItem()
  "myshop_customer_1235",
  100, // variantId
  2, // quantity
  "6522f4b2b857b289b920c12e", // promotionId
  {
    with: {
      items: {
        variant: {
          attributes: "all",
        },
        product: {
          attributes: { withKey: ["name"] },
        },
      },
    },
  }
);
const item = response.basket.items[0];

console.log(item.product.attributes.name.values.label);
console.log(`Size: ${item.variant.attributes.size.values.label}`);
console.log(`Quantity: ${item.quantity}`);
console.log(`PromotionId: ${item.promotionId}`);
// Hilfiger Shirt
// Size: S
// Quantity: 3
// PromotionId: 6522f4b2b857b289b920c12e
Response
{
  "type": "success",
  "basket": {
    "key": "myshop_customer_1235",
    "items": [
      {
        "key": "c4ca4238a0b923820dcc509a6f75849c",
        "packageId": 1,
        "quantity": 2,
        "status": "available",
        "displayData": {},
        "availableQuantity": 31,
        "deliveryForecast": {},
        "customData": {},
        "lowestPriorPrice": {
          "withTax": null,
          "relativeDifferenceToPrice": null
        },
        "price": {
          "total": {
            "currencyCode": "EUR",
            "withTax": 11970,
            "withoutTax": 10059,
            "recommendedRetailPrice": null,
            "tax": { "vat": { "amount": 1911, "rate": 0 } },
            "appliedReductions": []
          },
          "unit": {
            "currencyCode": "EUR",
            "withTax": 3990,
            "withoutTax": 3353,
            "recommendedRetailPrice": null,
            "tax": { "vat": { "amount": 637, "rate": 0 } },
            "appliedReductions": []
          }
        },
        "variant": {
          "id": 100,
          "referenceKey": "THS0906008000001_S",
          "attributes": {
            "size": {
              "id": 1002,
              "key": "size",
              "label": "Size",
              "type": "",
              "multiSelect": false,
              "values": { "id": 28, "label": "S", "value": "s" }
            }
          },
          "firstLiveAt": "0001-01-01T00:00:00+00:00",
          "createdAt": "2023-06-12T14:05:33+00:00",
          "updatedAt": "2023-07-07T11:50:06+00:00",
          "stock": {
            "supplierId": 1,
            "warehouseId": 1,
            "quantity": 31,
            "isSellableWithoutStock": false
          },
          "price": {
            "currencyCode": "EUR",
            "withTax": 3990,
            "withoutTax": 3353,
            "recommendedRetailPrice": null,
            "tax": { "vat": { "amount": 637, "rate": 0.19 } },
            "appliedReductions": []
          },
          "customData": {}
        },
        "product": {
          "id": 1,
          "isActive": true,
          "isSoldOut": false,
          "isNew": false,
          "createdAt": "2023-06-12T14:05:33+00:00",
          "updatedAt": "2023-06-12T14:05:34+00:00",
          "indexedAt": "2023-07-10T13:13:03+00:00",
          "firstLiveAt": "2023-06-12T14:05:33+00:00",
          "masterKey": "THS090600",
          "referenceKey": "THS0906008000001",
          "attributes": {
            "name": {
              "id": 20005,
              "key": "name",
              "label": "Name",
              "type": "",
              "multiSelect": false,
              "values": {
                "id": 20005,
                "label": "Hilfiger Shirt",
                "value": "name"
              }
            }
          },
          "images": [
            {
              "hash": "https://cdn.aboutstatic.com/file/cd81a5d37e4241686586812d9e179553?bg=F4F4F5&quality=75&trim=1&height=1067&width=800,https://cdn.aboutstatic.com/file/1c98f7fc408b9d2cca91abfbf5650df1?bg=F4F4F5&quality=75&height=1067&width=800, https://cdn.aboutstatic.com/f",
              "attributes": {}
            }
          ],
          "customData": {}
        },
        "itemGroup": null
        "promotionId": "6522f4b2b857b289b920c12e"
        "promotion": {
          "id": "6522f4b2b857b289b920c12e",
          "name": "Automatic Discount",
          "schedule": {
            "from": "2023-09-30T09:00:00Z",
            "to": "2023-12-30T18:00:00Z"
          },
          "isActive": true,
          "effect": {
            "type": "automatic_discount",
            "additionalData": {
              "type": "relative",
              "value": 20
            }
          },
          "conditions": [
            {
              "level": "global",
              "key": "mov_100",
              "condition": "payload.totals.withTax > 10000"
            }
          ],
          "customData": {
            "corePanel": {
              "viewType": "advanced"
            },
            "headerText": "Get 20% when your basket is over 100$"
          },
          "tiers": [
            {
              "id": 1, 
              "name": "Tier 1", 
              "MOV": 10000, 
              "effect": {
                "additionalData": {
                  "type": "relative",
                  "value": 25
                }
              }
            }
          ],
          "isValid": false,
          "failedConditions": [
            {
              "key": "mov_100",
              "level": "global"
            }
          ]
        }
      }
    ],
    "packages": [
      {
        "carrierKey": "DEFAULT",
        "deliveryDate": { "max": "2023-07-13", "min": "2023-07-11" },
        "id": 1
      }
    ],
    "cost": {
      "currencyCode": "EUR",
      "withTax": 11970,
      "withoutTax": 10059,
      "recommendedRetailPrice": null,
      "tax": { "vat": { "amount": 1911, "rate": 0 } },
      "appliedReductions": []
    }
  }
}

Add item with promotionCode

It is also possible to add an item to the basket with a promotionCode. It works the same way as with a promotionId and you also need to include the promotionId.

curl --location -X POST 'https://{{tenant-space}}.storefront.api.scayle.cloud/v1/baskets/myshop_customer_1234/items?shopId={{shopId}}&with=items.product.attributes%2Citems.variant.attributes%3Akey(name)' \
--header 'Content-Type: application/json' \
--data '{
  "quantity": 3,
  "variantId": 1,
  "promotionId": "6522f4b2b857b289b920c12e",
  "promotionCode": "promocode123"
}'
Response
{
  "type": "success",
  "basket": {
    "key": "myshop_customer_1235",
    "items": [
      {
        "key": "c4ca4238a0b923820dcc509a6f75849c",
        "packageId": 1,
        "quantity": 2,
        "status": "available",
        "displayData": {},
        "availableQuantity": 31,
        "deliveryForecast": {},
        "customData": {},
        "lowestPriorPrice": {
          "withTax": null,
          "relativeDifferenceToPrice": null
        },
        "price": {
          "total": {
            "currencyCode": "EUR",
            "withTax": 11970,
            "withoutTax": 10059,
            "recommendedRetailPrice": null,
            "tax": { "vat": { "amount": 1911, "rate": 0 } },
            "appliedReductions": []
          },
          "unit": {
            "currencyCode": "EUR",
            "withTax": 3990,
            "withoutTax": 3353,
            "recommendedRetailPrice": null,
            "tax": { "vat": { "amount": 637, "rate": 0 } },
            "appliedReductions": []
          }
        },
        "variant": {
          "id": 100,
          "referenceKey": "THS0906008000001_S",
          "attributes": {
            "size": {
              "id": 1002,
              "key": "size",
              "label": "Size",
              "type": "",
              "multiSelect": false,
              "values": { "id": 28, "label": "S", "value": "s" }
            }
          },
          "firstLiveAt": "0001-01-01T00:00:00+00:00",
          "createdAt": "2023-06-12T14:05:33+00:00",
          "updatedAt": "2023-07-07T11:50:06+00:00",
          "stock": {
            "supplierId": 1,
            "warehouseId": 1,
            "quantity": 31,
            "isSellableWithoutStock": false
          },
          "price": {
            "currencyCode": "EUR",
            "withTax": 3990,
            "withoutTax": 3353,
            "recommendedRetailPrice": null,
            "tax": { "vat": { "amount": 637, "rate": 0.19 } },
            "appliedReductions": []
          },
          "customData": {}
        },
        "product": {
          "id": 1,
          "isActive": true,
          "isSoldOut": false,
          "isNew": false,
          "createdAt": "2023-06-12T14:05:33+00:00",
          "updatedAt": "2023-06-12T14:05:34+00:00",
          "indexedAt": "2023-07-10T13:13:03+00:00",
          "firstLiveAt": "2023-06-12T14:05:33+00:00",
          "masterKey": "THS090600",
          "referenceKey": "THS0906008000001",
          "attributes": {
            "name": {
              "id": 20005,
              "key": "name",
              "label": "Name",
              "type": "",
              "multiSelect": false,
              "values": {
                "id": 20005,
                "label": "Hilfiger Shirt",
                "value": "name"
              }
            }
          },
          "images": [
            {
              "hash": "https://cdn.aboutstatic.com/file/cd81a5d37e4241686586812d9e179553?bg=F4F4F5&quality=75&trim=1&height=1067&width=800,https://cdn.aboutstatic.com/file/1c98f7fc408b9d2cca91abfbf5650df1?bg=F4F4F5&quality=75&height=1067&width=800, https://cdn.aboutstatic.com/f",
              "attributes": {}
            }
          ],
          "customData": {}
        },
        "itemGroup": null
        "promotionId": "6522f4b2b857b289b920c12e"
        "promotion": {
          "id": "6522f4b2b857b289b920c12e",
          "name": "Automatic Discount",
          "schedule": {
            "from": "2023-09-30T09:00:00Z",
            "to": "2023-12-30T18:00:00Z"
          },
          "isActive": true,
          "effect": {
            "type": "automatic_discount",
            "additionalData": {
              "type": "relative",
              "value": 20
            }
          },
          "conditions": [
            {
              "level": "global",
              "key": "mov_100",
              "condition": "payload.totals.withTax > 10000"
            }
          ],
          "customData": {
            "corePanel": {
              "viewType": "advanced"
            },
            "headerText": "Get 20% when your basket is over 100$"
          },
          "tiers": [
            {
              "id": 1, 
              "name": "Tier 1", 
              "MOV": 10000, 
              "effect": {
                "additionalData": {
                  "type": "relative",
                  "value": 25
                }
              }
            }
          ],
          "isValid": false,
          "failedConditions": [
            {
              "key": "mov_100",
              "level": "global"
            }
          ]
        }
      }
    ],
    "packages": [
      {
        "carrierKey": "DEFAULT",
        "deliveryDate": { "max": "2023-07-13", "min": "2023-07-11" },
        "id": 1
      }
    ],
    "cost": {
      "currencyCode": "EUR",
      "withTax": 11970,
      "withoutTax": 10059,
      "recommendedRetailPrice": null,
      "tax": { "vat": { "amount": 1911, "rate": 0 } },
      "appliedReductions": []
    }
  }
}

Get all basket items

We can request the current state of a basket by simply passing the basket key. Here we can also define which attributes of the product and its variant we want to retrieve.

Note that you need to have an item in the basket.

Optionally you can add a campaignKey to retrieve updated discounted prices.

// Get a specific basket by its key
const { basket } = await client.basket.get("myshop_customer_1234", {
  items: {
    product: {
        attributes: { withKey: ["name","brand"] },
      },
    variant: {
      attributes: "all"
    },
  },
  campaignKey: 'promo_test_20'
});

console.log(
  `Costs: ${basket.basket.cost.withTax / 100}${basket.basket.cost.currencyCode}`
);
// Costs: 119.7EUR
Response
{
  "key": "myshop_customer_1234",
  "items": [
    {
      "key": "640752001b09dc131087c3620227027c",
      "packageId": 1,
      "quantity": 19,
      "status": "available",
      "displayData": {},
      "availableQuantity": 31,
      "customData": {},
      "lowestPriorPrice": {
        "withTax": null,
        "relativeDifferenceToPrice": null
      },
      "price": {
        "total": {
          "currencyCode": "EUR",
          "withTax": 75810,
          "withoutTax": 63707,
          "recommendedRetailPrice": null,
          "tax": { "vat": { "amount": 12104, "rate": 0 } },
          "appliedReductions": []
        },
        "unit": {
          "currencyCode": "EUR",
          "withTax": 3990,
          "withoutTax": 3353,
          "recommendedRetailPrice": null,
          "tax": { "vat": { "amount": 637, "rate": 0 } },
          "appliedReductions": []
        }
      },
      "variant": {
        "id": 1,
        "referenceKey": "THS0906008000001_S",
        "attributes": {
          "size": {
            "id": 1002,
            "key": "size",
            "label": "Size",
            "type": "",
            "multiSelect": false,
            "values": { "id": 28, "label": "S", "value": "s" }
          }
        },
        "firstLiveAt": "0001-01-01T00:00:00+00:00",
        "createdAt": "2023-06-12T14:05:33+00:00",
        "updatedAt": "2023-08-28T11:19:33+00:00",
        "stock": {
          "supplierId": 1,
          "warehouseId": 1,
          "quantity": 31,
          "isSellableWithoutStock": false
        },
        "price": {
          "currencyCode": "EUR",
          "withTax": 3990,
          "withoutTax": 3353,
          "recommendedRetailPrice": null,
          "tax": { "vat": { "amount": 637, "rate": 0.19 } },
          "appliedReductions": []
        },
        "customData": { "deliveryEstimate": [] }
      },
      "product": {
        "id": 1,
        "isActive": true,
        "isSoldOut": false,
        "isNew": false,
        "createdAt": "2023-06-12T14:05:33+00:00",
        "updatedAt": "2023-06-12T14:05:34+00:00",
        "indexedAt": "2023-09-05T12:42:43+00:00",
        "firstLiveAt": "2023-06-12T14:05:33+00:00",
        "masterKey": "THS090600",
        "referenceKey": "THS0906008000001",
        "attributes": {
          "name": {
            "id": 20005,
            "key": "name",
            "label": "Name",
            "type": "",
            "multiSelect": false,
            "values": {
              "id": 20005,
              "label": "Hilfiger Shirt",
              "value": "name"
            }
          },
          "brand": {
            "id": 550,
            "key": "brand",
            "label": "Marke",
            "type": "",
            "multiSelect": false,
            "values": {
              "id": 10,
              "label": "Tommy Hilfiger",
              "value": "tommy_hilfiger"
            }
          }
        },
        "images": [
          {
            "hash": "https://cdn.aboutstatic.com/file/cd81a5d37e4241686586812d9e179553?bg=F4F4F5&quality=75&trim=1&height=1067&width=800,https://cdn.aboutstatic.com/file/1c98f7fc408b9d2cca91abfbf5650df1?bg=F4F4F5&quality=75&height=1067&width=800, https://cdn.aboutstatic.com/f",
            "attributes": {}
          }
        ],
        "customData": {}
      },
      "itemGroup": {
        "id": "sun_glasses_hhbdz6",
        "isMainItem": true,
        "isRequired": true
      },
      "promotionId": null
      "promotion": null
    }
  ],
  "packages": [
    {
      "carrierKey": "DEFAULT",
      "deliveryDate": { "max": "2023-09-18", "min": "2023-09-11" },
      "id": 1
    }
  ],
  "cost": {
    "currencyCode": "EUR",
    "withTax": 75810,
    "withoutTax": 63707,
    "recommendedRetailPrice": null,
    "tax": { "vat": { "amount": 12104, "rate": 0 } },
    "appliedReductions": []
  }
}

Get Basket items with Applicable Promotions

Retrieve a list of all applicable promotions along with basket items by including the
?with=applicablePromotions query parameter. To display applicable promotions, submit a basket item without the "promotionId" parameter. If the "promotionId" is included (not null), the promotion becomes directly associated with the item, and no other applicable promotions will be displayed.

Optionally you can add a with=applicablePromotions to retrieve active applicable promotions.

// Get a specific basket by its key with applicablePromotions
const { basket } = await client.basket.get("myshop_customer_1234", {
    with: 'applicablePromotions'
});

console.log(
    `Number of Applicable Promotions: ${basket.applicablePromotions.length}`
);
// Number of Applicable Promotions: 1
Response
{
  "key": "myshop_customer_1234",
  "items": [
    {
      "key": "44f364e11b019eb381b86866331a9993",
      "packageId": 2,
      "quantity": 20,
      "status": "available",
      "displayData": {},
      "availableQuantity": 70,
      "customData": {},
      "lowestPriorPrice": {
        "withTax": null,
        "relativeDifferenceToPrice": null
      },
      "price": {
        "total": {
          "currencyCode": "EUR",
          "withTax": 2400,
          "withoutTax": 2020,
          "recommendedRetailPrice": null,
          "tax": {
            "vat": {
              "amount": 380,
              "rate": 0
            }
          },
          "appliedReductions": [
            {
              "category": "promotion",
              "type": "relative",
              "amount": {
                "relative": 0.2,
                "absoluteWithTax": 600,
                "absoluteTax": 100,
                "absoluteWithoutTax": 500
              }
            }
          ]
        },
        "unit": {
          "currencyCode": "EUR",
          "withTax": 120,
          "withoutTax": 101,
          "recommendedRetailPrice": null,
          "tax": {
            "vat": {
              "amount": 19,
              "rate": 0
            }
          },
          "appliedReductions": [
            {
              "category": "promotion",
              "type": "relative",
              "amount": {
                "relative": 0.2,
                "absoluteWithTax": 30,
                "absoluteTax": 5,
                "absoluteWithoutTax": 25
              }
            }
          ]
        }
      },
      "variant": {
        "id": 33378,
        "referenceKey": "default-merchant-fallback-test-v9",
        "firstLiveAt": "2023-11-16T01:04:38+00:00",
        "createdAt": "2023-11-14T11:03:14+00:00",
        "updatedAt": "2023-11-16T01:04:38+00:00",
        "stock": {
          "supplierId": 1,
          "warehouseId": 9,
          "quantity": 70,
          "isSellableWithoutStock": false
        },
        "price": {
          "currencyCode": "EUR",
          "withTax": 150,
          "withoutTax": 126,
          "recommendedRetailPrice": null,
          "tax": {
            "vat": {
              "amount": 24,
              "rate": 0.19
            }
          },
          "appliedReductions": []
        },
        "customData": {
          "subscriptionEligibility": false
        }
      },
      "product": {
        "id": 17381,
        "isActive": true,
        "isSoldOut": false,
        "isNew": true,
        "createdAt": "2023-11-14T10:00:30+00:00",
        "updatedAt": "2023-11-14T10:17:49+00:00",
        "indexedAt": "2023-11-23T10:09:32+00:00",
        "firstLiveAt": "2023-11-16T01:04:38+00:00",
        "masterKey": "default-merchant-fallback-test-m6",
        "referenceKey": "default-merchant-fallback-test-p6",
        "images": [],
        "customData": {}
      },
      "itemGroup": null,
      "promotionId": null,
      "promotion": null
    }
  ],
  "packages": [
    {
      "carrierKey": "zelim-test",
      "deliveryDate": {
        "max": "2023-11-27",
        "min": "2023-11-24"
      },
      "id": 1
    },
    {
      "carrierKey": "zelim-test",
      "deliveryDate": {
        "max": "2023-11-27",
        "min": "2023-11-24"
      },
      "id": 2
    }
  ],
  "cost": {
    "currencyCode": "EUR",
    "withTax": 10400,
    "withoutTax": 8740,
    "recommendedRetailPrice": null,
    "tax": {
      "vat": {
        "amount": 1660,
        "rate": 0
      }
    },
    "appliedReductions": []
  }
  "applicablePromotions": [
    {
      "promotion": {
        "id": "6565fdd53740d2825e72e08f",
        "name": "SAPIQA-B item 155 pId2031 vId17846 EUR G 44390",
        "schedule": {
          "from": "2023-11-28T11:00:00Z",
          "to": "2023-12-09T11:00:00Z"
        },
        "isActive": true,
        "effect": {
          "type": "buy_x_get_y",
          "additionalData": {
            "eligibleItemsQuantity": 2,
            "maxCount": 1,
            "maxCountType": "per_eligible_items_quantity",
            "variantIds": [
              44390
            ]
          }
        },
        "conditions": [
          {
            "level": "item",
            "key": "price==3999",
            "condition": "item.unitPrice.withTax==3999"
          }
        ],
        "customData": {
          "corePanel": {
            "viewType": "advanced"
          }
        },
        "tiers": [
          {
            "id": 1, 
            "name": "Tier 1", 
            "MOV": 10000, 
            "effect": {
              "additionalData": {
                "type": "relative",
                "value": 25
              }
            }
          }
        ]
      },
      "itemId": "e215aa18dc849e9b53c7c90f59d455d5"
    }
  ]
}

Get Basket items with Applicable Promotions by Promotion Code

Retrieve a list of all applicable promotions along with basket items by promotion code.

curl --location --request POST 'https://{{tenant-space}}.storefront.api.scayle.cloud/v1/basket/{{basketId}}/promotion-code?shopId={{shopId}}' \
--header 'X-Access-Token: {{ACCESSTOKEN}}'
--data '{
 "promotionCode": "promocode123",
}'
Response
{
  "key": "myshop_customer_1234",
  "items": [
    {
      "key": "44f364e11b019eb381b86866331a9993",
      "packageId": 2,
      "quantity": 20,
      "status": "available",
      "displayData": {},
      "availableQuantity": 70,
      "customData": {},
      "lowestPriorPrice": {
        "withTax": null,
        "relativeDifferenceToPrice": null
      },
      "price": {
        "total": {
          "currencyCode": "EUR",
          "withTax": 2400,
          "withoutTax": 2020,
          "recommendedRetailPrice": null,
          "tax": {
            "vat": {
              "amount": 380,
              "rate": 0
            }
          },
          "appliedReductions": [
            {
              "category": "promotion",
              "type": "relative",
              "amount": {
                "relative": 0.2,
                "absoluteWithTax": 600,
                "absoluteTax": 100,
                "absoluteWithoutTax": 500
              }
            }
          ]
        },
        "unit": {
          "currencyCode": "EUR",
          "withTax": 120,
          "withoutTax": 101,
          "recommendedRetailPrice": null,
          "tax": {
            "vat": {
              "amount": 19,
              "rate": 0
            }
          },
          "appliedReductions": [
            {
              "category": "promotion",
              "type": "relative",
              "amount": {
                "relative": 0.2,
                "absoluteWithTax": 30,
                "absoluteTax": 5,
                "absoluteWithoutTax": 25
              }
            }
          ]
        }
      },
      "variant": {
        "id": 33378,
        "referenceKey": "default-merchant-fallback-test-v9",
        "firstLiveAt": "2023-11-16T01:04:38+00:00",
        "createdAt": "2023-11-14T11:03:14+00:00",
        "updatedAt": "2023-11-16T01:04:38+00:00",
        "stock": {
          "supplierId": 1,
          "warehouseId": 9,
          "quantity": 70,
          "isSellableWithoutStock": false
        },
        "price": {
          "currencyCode": "EUR",
          "withTax": 150,
          "withoutTax": 126,
          "recommendedRetailPrice": null,
          "tax": {
            "vat": {
              "amount": 24,
              "rate": 0.19
            }
          },
          "appliedReductions": []
        },
        "customData": {
          "subscriptionEligibility": false
        }
      },
      "product": {
        "id": 17381,
        "isActive": true,
        "isSoldOut": false,
        "isNew": true,
        "createdAt": "2023-11-14T10:00:30+00:00",
        "updatedAt": "2023-11-14T10:17:49+00:00",
        "indexedAt": "2023-11-23T10:09:32+00:00",
        "firstLiveAt": "2023-11-16T01:04:38+00:00",
        "masterKey": "default-merchant-fallback-test-m6",
        "referenceKey": "default-merchant-fallback-test-p6",
        "images": [],
        "customData": {}
      },
      "itemGroup": null,
      "promotionId": null,
      "promotion": null
    }
  ],
  "packages": [
    {
      "carrierKey": "zelim-test",
      "deliveryDate": {
        "max": "2023-11-27",
        "min": "2023-11-24"
      },
      "id": 1
    },
    {
      "carrierKey": "zelim-test",
      "deliveryDate": {
        "max": "2023-11-27",
        "min": "2023-11-24"
      },
      "id": 2
    }
  ],
  "cost": {
    "currencyCode": "EUR",
    "withTax": 10400,
    "withoutTax": 8740,
    "recommendedRetailPrice": null,
    "tax": {
      "vat": {
        "amount": 1660,
        "rate": 0
      }
    },
    "appliedReductions": []
  }
  "applicablePromotions": [
    {
      "promotion": {
        "id": "6565fdd53740d2825e72e08f",
        "name": "SAPIQA-B item 155 pId2031 vId17846 EUR G 44390",
        "schedule": {
          "from": "2023-11-28T11:00:00Z",
          "to": "2023-12-09T11:00:00Z"
        },
        "isActive": true,
        "effect": {
          "type": "buy_x_get_y",
          "additionalData": {
            "eligibleItemsQuantity": 2,
            "maxCount": 1,
            "maxCountType": "per_eligible_items_quantity",
            "variantIds": [
              44390
            ]
          }
        },
        "conditions": [
          {
            "level": "item",
            "key": "price==3999",
            "condition": "item.unitPrice.withTax==3999"
          }
        ],
        "customData": {
          "corePanel": {
            "viewType": "advanced"
          }
        },
        "tiers": [
          {
            "id": 1, 
            "name": "Tier 1", 
            "MOV": 10000, 
            "effect": {
              "additionalData": {
                "type": "relative",
                "value": 25
              }
            }
          }
        ]
      },
      "itemId": "e215aa18dc849e9b53c7c90f59d455d5"
    }
  ]
}

Change quantity

Sometimes our customers change their mind and change quantity. We can update basket items by passing the item key and the updated quantity.

ParametertypeRequiredDescription
basketKeystringtrueKey of the basket.
itemKeystringtrueKey of the basket item.
quantityintegertrueNew quantity of the item.
promotionIdstringfalseID of promotion to be updated to the basket item
promotionCodestringfalseCode of promotion to be updated to the basket item
withobjectfalseDefines which optional fields should be included in the response. Contained as with inside the options object (second parameter).
// Update a basket item and set quantity to 1
const { basket } = await client.basket.get("myshop_customer_1234");
console.log(`Quantity: ${basket.items[0].quantity}`);
// Quantity: 3

const item = basket.items[0];
const { basket: updatedBasket } = await client.basket.updateItem(
  "myshop_customer_1234",
  item.key,
  1
);
console.log(`Quantity: ${updatedBasket.items[0].quantity}`);
// Quantity: 1
Response
{
    "type": "success",
    "basket": {
        "key": "myshop_customer_1234",
        "items": [
            {
                "key": "c4ca4238a0b923820dcc509a6f75849b",
                "packageId": 1,
                "quantity": 1,
                "status": "available",
                "displayData": {},
                "availableQuantity": 31,
                "deliveryForecast": {},
                "customData": {},
                "lowestPriorPrice": {
                    "withTax": null,
                    "relativeDifferenceToPrice": null
                },
                "price": {
                    "total": {
                        "currencyCode": "EUR",
                        "withTax": 3990,
                        "withoutTax": 3353,
                        "recommendedRetailPrice": null,
                        "tax": { "vat": { "amount": 637, "rate": 0 } },
                        "appliedReductions": []
                    },
                    "unit": {
                        "currencyCode": "EUR",
                        "withTax": 3990,
                        "withoutTax": 3353,
                        "recommendedRetailPrice": null,
                        "tax": { "vat": { "amount": 637, "rate": 0 } },
                        "appliedReductions": []
                    }
                },
                "variant": {
                    "id": 1,
                    "referenceKey": "THS0906008000001_S",
                    "firstLiveAt": "0001-01-01T00:00:00+00:00",
                    "createdAt": "2023-06-12T14:05:33+00:00",
                    "updatedAt": "2023-07-07T11:50:06+00:00",
                    "stock": {
                        "supplierId": 1,
                        "warehouseId": 1,
                        "quantity": 31,
                        "isSellableWithoutStock": false
                    },
                    "price": {
                        "currencyCode": "EUR",
                        "withTax": 3990,
                        "withoutTax": 3353,
                        "recommendedRetailPrice": null,
                        "tax": { "vat": { "amount": 637, "rate": 0.19 } },
                        "appliedReductions": []
                    },
                    "customData": {}
                },
                "product": {
                    "id": 1,
                    "isActive": true,
                    "isSoldOut": false,
                    "isNew": false,
                    "createdAt": "2023-06-12T14:05:33+00:00",
                    "updatedAt": "2023-06-12T14:05:34+00:00",
                    "indexedAt": "2023-07-11T20:13:33+00:00",
                    "firstLiveAt": "2023-06-12T14:05:33+00:00",
                    "masterKey": "THS090600",
                    "referenceKey": "THS0906008000001",
                    "images": [
                        {
                            "hash": "https://cdn.aboutstatic.com/file/cd81a5d37e4241686586812d9e179553?bg=F4F4F5&quality=75&trim=1&height=1067&width=800,https://cdn.aboutstatic.com/file/1c98f7fc408b9d2cca91abfbf5650df1?bg=F4F4F5&quality=75&height=1067&width=800, https://cdn.aboutstatic.com/f"
                        }
                    ],
                    "customData": {}
                },
                "itemGroup": null
                "promotionId": null
                "promotion": null
            }
        ],
        "packages": [
            {
                "carrierKey": "DEFAULT",
                "deliveryDate": { "max": "2023-07-14", "min": "2023-07-12" },
                "id": 1
            }
        ],
        "cost": {
            "currencyCode": "EUR",
            "withTax": 3990,
            "withoutTax": 3353,
            "recommendedRetailPrice": null,
            "tax": { "vat": { "amount": 637, "rate": 0 } },
            "appliedReductions": []
        }
    }
}

Update Basket Item with promotionId

We can update promotionId to the basket item by passing the item key, like so:

// Update a basket item and set promotionId to "6522f4b2b857b289b920c65c"
const { basket } = await client.basket.get("myshop_customer_1236");
console.log(`PromotionId: ${basket.items[0].promotionId}`);
// PromotionId: null

const item = basket.items[0];
const { basket: updatedBasket } = await client.basket.updateItem(
  "myshop_customer_1236",
  item.key,
  item.quantity,
  {promotionId:"6522f4b2b857b289b920c65c"}
);
console.log(`PromotionId: ${updatedBasket.items[0].promotionId}`);
// PromotionId: "6522f4b2b857b289b920c65c"
Response
{
  "key": "myshop_customer_1236",
  "items": [
    {
      "key": "44f364e11b019eb381b86866331a9993",
      "packageId": 2,
      "quantity": 20,
      "status": "available",
      "displayData": {},
      "availableQuantity": 70,
      "customData": {},
      "lowestPriorPrice": {
        "withTax": null,
        "relativeDifferenceToPrice": null
      },
      "price": {
        "total": {
          "currencyCode": "EUR",
          "withTax": 2400,
          "withoutTax": 2020,
          "recommendedRetailPrice": null,
          "tax": {
            "vat": {
              "amount": 380,
              "rate": 0
            }
          },
          "appliedReductions": [
            {
              "category": "promotion",
              "type": "relative",
              "amount": {
                "relative": 0.2,
                "absoluteWithTax": 600,
                "absoluteTax": 100,
                "absoluteWithoutTax": 500
              }
            }
          ]
        },
        "unit": {
          "currencyCode": "EUR",
          "withTax": 120,
          "withoutTax": 101,
          "recommendedRetailPrice": null,
          "tax": {
            "vat": {
              "amount": 19,
              "rate": 0
            }
          },
          "appliedReductions": [
            {
              "category": "promotion",
              "type": "relative",
              "amount": {
                "relative": 0.2,
                "absoluteWithTax": 30,
                "absoluteTax": 5,
                "absoluteWithoutTax": 25
              }
            }
          ]
        }
      },
      "variant": {
        "id": 33378,
        "referenceKey": "default-merchant-fallback-test-v9",
        "firstLiveAt": "2023-11-16T01:04:38+00:00",
        "createdAt": "2023-11-14T11:03:14+00:00",
        "updatedAt": "2023-11-16T01:04:38+00:00",
        "stock": {
          "supplierId": 1,
          "warehouseId": 9,
          "quantity": 70,
          "isSellableWithoutStock": false
        },
        "price": {
          "currencyCode": "EUR",
          "withTax": 150,
          "withoutTax": 126,
          "recommendedRetailPrice": null,
          "tax": {
            "vat": {
              "amount": 24,
              "rate": 0.19
            }
          },
          "appliedReductions": []
        },
        "customData": {
          "subscriptionEligibility": false
        }
      },
      "product": {
        "id": 17381,
        "isActive": true,
        "isSoldOut": false,
        "isNew": true,
        "createdAt": "2023-11-14T10:00:30+00:00",
        "updatedAt": "2023-11-14T10:17:49+00:00",
        "indexedAt": "2023-11-23T10:09:32+00:00",
        "firstLiveAt": "2023-11-16T01:04:38+00:00",
        "masterKey": "default-merchant-fallback-test-m6",
        "referenceKey": "default-merchant-fallback-test-p6",
        "images": [],
        "customData": {}
      },
      "itemGroup": null,
      "promotionId": "6522f4b2b857b289b920c65c",
      "promotion": {
        "id": "6522f4b2b857b289b920c65c",
        "name": "Automatic Discount",
        "schedule": {
          "from": "2023-09-30T09:00:00Z",
          "to": "2023-12-30T18:00:00Z"
        },
        "isActive": true,
        "effect": {
          "type": "automatic_discount",
          "additionalData": {
            "type": "relative",
            "value": 20
          }
        },
        "conditions": [
          {
            "level": "global",
            "key": "mov_100",
            "condition": "payload.totals.withTax > 10000"
          }
        ],
        "customData": {
          "corePanel": {
            "viewType": "advanced"
          },
          "headerText": "Get 20% when your basket is over 100$"
        },
        "tiers": [
          {
            "id": 1, 
            "name": "Tier 1", 
            "MOV": 10000, 
            "effect": {
              "additionalData": {
                "type": "relative",
                "value": 25
              }
            }
          }
        ],
        "isValid": true,
        "failedConditions": []
      }
    },
    {
        "key": "b33e197c4fdad374692ca3d65509d771",
        "packageId": 1,
        "quantity": 10,
        "status": "available",
        "displayData": {},
        "availableQuantity": 10,
        "customData": {},
        "lowestPriorPrice": {
          "withTax": 480,
          "relativeDifferenceToPrice": 0.66
        },
      "price": {
        "total": {
          "currencyCode": "EUR",
          "withTax": 8000,
          "withoutTax": 6720,
          "recommendedRetailPrice": null,
          "tax": {
            "vat": {
              "amount": 1280,
              "rate": 0
            }
          },
          "appliedReductions": [
            {
              "category": "sale",
              "type": "relative",
              "amount": {
                "relative": 0.2,
                "absoluteWithTax": 2000
              }
            }
          ]
        },
        "unit": {
          "currencyCode": "EUR",
          "withTax": 800,
          "withoutTax": 672,
          "recommendedRetailPrice": null,
          "tax": {
            "vat": {
              "amount": 128,
              "rate": 0
            }
          },
          "appliedReductions": [
            {
              "category": "sale",
              "type": "relative",
              "amount": {
                "relative": 0.2,
                "absoluteWithTax": 200
              }
            }
          ]
        }
      },
      "variant": {
        "id": 32707,
        "referenceKey": "TC32 BAPIQAZSAP varints1.referenceKey BAPIQA test w Mallory",
        "firstLiveAt": "2023-07-17T14:01:22+00:00",
        "createdAt": "2023-07-17T14:01:04+00:00",
        "updatedAt": "2023-11-09T16:05:56+00:00",
        "stock": {
          "supplierId": 1,
          "warehouseId": 4,
          "quantity": 10,
          "isSellableWithoutStock": false
        },
        "price": {
          "currencyCode": "EUR",
          "withTax": 800,
          "withoutTax": 672,
          "recommendedRetailPrice": 1000,
          "tax": {
            "vat": {
              "amount": 128,
              "rate": 0.19
            }
          },
          "appliedReductions": [
            {
              "category": "sale",
              "type": "relative",
              "amount": {
                "relative": 0.2,
                "absoluteWithTax": 200
              }
            }
          ],
          "reference": {
            "withoutTax": 84,
            "withTax": 100,
            "size": 100,
            "unit": "ml"
          }
        },
        "customData": {
          "subscriptionEligibility": false,
          "deliveryEstimate": []
        }
      },
      "product": {
        "id": 16934,
        "isActive": true,
        "isSoldOut": false,
        "isNew": false,
        "createdAt": "2023-07-17T14:01:04+00:00",
        "updatedAt": "2023-08-17T10:49:55+00:00",
        "indexedAt": "2023-11-23T10:09:32+00:00",
        "firstLiveAt": "2023-07-17T14:01:21+00:00",
        "masterKey": "TC32 BAPIQAZSAP master.referenceKey BAPIQA test w Mallory",
        "referenceKey": "TC32 BAPIQAZSAP referenceKey BAPIQA test w Mallory",
        "images": [
          {
            "hash": "images/084dace7d7ff691e97982fa554113c29"
          }
        ],
        "customData": {
          "subscriptionDiscountSubsequentPercentage": 10,
          "wedwde": "Prepearation for ppk w 'promotionKey': null,",
          "productCustomData": "productCustomData",
          "subscriptionIntervals": "[\"1 month\", \"3 month\", \"6 month\", \"12 month\"]",
          "subscriptionEligibility": false
        }
      },
      "itemGroup": null,
      "promotionId": null,
      "promotion": null
    }
  ],
  "packages": [
    {
      "carrierKey": "zelim-test",
      "deliveryDate": {
        "max": "2023-11-27",
        "min": "2023-11-24"
      },
      "id": 1
    },
    {
      "carrierKey": "zelim-test",
      "deliveryDate": {
        "max": "2023-11-27",
        "min": "2023-11-24"
      },
      "id": 2
    }
  ],
  "cost": {
    "currencyCode": "EUR",
    "withTax": 10400,
    "withoutTax": 8740,
    "recommendedRetailPrice": null,
    "tax": {
      "vat": {
        "amount": 1660,
        "rate": 0
      }
    },
    "appliedReductions": [
      {
        "category": "sale",
        "type": "relative",
        "amount": {
          "relative": 0.15,
          "absoluteWithTax": 2000
        }
      },
      {
        "category": "promotion",
        "type": "relative",
        "amount": {
          "relative": 0.05,
          "absoluteWithTax": 600,
          "absoluteTax": 100,
          "absoluteWithoutTax": 500
        }
      }
    ]
  }
}

Update Basket Item with promotionCode

We can update the promotionCode of the basket item by passing the item key, like so:

curl --location -X PATCH 'https://{{tenant-space}}.storefront.api.scayle.cloud/v1/baskets/myshop_customer_1234/items/{{itemKey}}?shopId={{shopId}}' \
--header 'Content-Type: application/json' \
--data '{
  "quantity": 1,
  "promotionId": "6522f4b2b857b289b920c65c",
  "promotionCode": "promocode123"
}'
Response
{
  "key": "myshop_customer_1236",
  "items": [
    {
      "key": "44f364e11b019eb381b86866331a9993",
      "packageId": 2,
      "quantity": 20,
      "status": "available",
      "displayData": {},
      "availableQuantity": 70,
      "customData": {},
      "lowestPriorPrice": {
        "withTax": null,
        "relativeDifferenceToPrice": null
      },
      "price": {
        "total": {
          "currencyCode": "EUR",
          "withTax": 2400,
          "withoutTax": 2020,
          "recommendedRetailPrice": null,
          "tax": {
            "vat": {
              "amount": 380,
              "rate": 0
            }
          },
          "appliedReductions": [
            {
              "category": "promotion",
              "type": "relative",
              "amount": {
                "relative": 0.2,
                "absoluteWithTax": 600,
                "absoluteTax": 100,
                "absoluteWithoutTax": 500
              }
            }
          ]
        },
        "unit": {
          "currencyCode": "EUR",
          "withTax": 120,
          "withoutTax": 101,
          "recommendedRetailPrice": null,
          "tax": {
            "vat": {
              "amount": 19,
              "rate": 0
            }
          },
          "appliedReductions": [
            {
              "category": "promotion",
              "type": "relative",
              "amount": {
                "relative": 0.2,
                "absoluteWithTax": 30,
                "absoluteTax": 5,
                "absoluteWithoutTax": 25
              }
            }
          ]
        }
      },
      "variant": {
        "id": 33378,
        "referenceKey": "default-merchant-fallback-test-v9",
        "firstLiveAt": "2023-11-16T01:04:38+00:00",
        "createdAt": "2023-11-14T11:03:14+00:00",
        "updatedAt": "2023-11-16T01:04:38+00:00",
        "stock": {
          "supplierId": 1,
          "warehouseId": 9,
          "quantity": 70,
          "isSellableWithoutStock": false
        },
        "price": {
          "currencyCode": "EUR",
          "withTax": 150,
          "withoutTax": 126,
          "recommendedRetailPrice": null,
          "tax": {
            "vat": {
              "amount": 24,
              "rate": 0.19
            }
          },
          "appliedReductions": []
        },
        "customData": {
          "subscriptionEligibility": false
        }
      },
      "product": {
        "id": 17381,
        "isActive": true,
        "isSoldOut": false,
        "isNew": true,
        "createdAt": "2023-11-14T10:00:30+00:00",
        "updatedAt": "2023-11-14T10:17:49+00:00",
        "indexedAt": "2023-11-23T10:09:32+00:00",
        "firstLiveAt": "2023-11-16T01:04:38+00:00",
        "masterKey": "default-merchant-fallback-test-m6",
        "referenceKey": "default-merchant-fallback-test-p6",
        "images": [],
        "customData": {}
      },
      "itemGroup": null,
      "promotionId": "6522f4b2b857b289b920c65c",
      "promotion": {
        "id": "6522f4b2b857b289b920c65c",
        "name": "Automatic Discount",
        "schedule": {
          "from": "2023-09-30T09:00:00Z",
          "to": "2023-12-30T18:00:00Z"
        },
        "isActive": true,
        "effect": {
          "type": "automatic_discount",
          "additionalData": {
            "type": "relative",
            "value": 20
          }
        },
        "conditions": [
          {
            "level": "global",
            "key": "mov_100",
            "condition": "payload.totals.withTax > 10000"
          }
        ],
        "customData": {
          "corePanel": {
            "viewType": "advanced"
          },
          "headerText": "Get 20% when your basket is over 100$"
        },
        "tiers": [
          {
            "id": 1, 
            "name": "Tier 1", 
            "MOV": 10000, 
            "effect": {
              "additionalData": {
                "type": "relative",
                "value": 25
              }
            }
          }
        ],
        "isValid": true,
        "failedConditions": []
      }
    },
    {
        "key": "b33e197c4fdad374692ca3d65509d771",
        "packageId": 1,
        "quantity": 10,
        "status": "available",
        "displayData": {},
        "availableQuantity": 10,
        "customData": {},
        "lowestPriorPrice": {
          "withTax": 480,
          "relativeDifferenceToPrice": 0.66
        },
      "price": {
        "total": {
          "currencyCode": "EUR",
          "withTax": 8000,
          "withoutTax": 6720,
          "recommendedRetailPrice": null,
          "tax": {
            "vat": {
              "amount": 1280,
              "rate": 0
            }
          },
          "appliedReductions": [
            {
              "category": "sale",
              "type": "relative",
              "amount": {
                "relative": 0.2,
                "absoluteWithTax": 2000
              }
            }
          ]
        },
        "unit": {
          "currencyCode": "EUR",
          "withTax": 800,
          "withoutTax": 672,
          "recommendedRetailPrice": null,
          "tax": {
            "vat": {
              "amount": 128,
              "rate": 0
            }
          },
          "appliedReductions": [
            {
              "category": "sale",
              "type": "relative",
              "amount": {
                "relative": 0.2,
                "absoluteWithTax": 200
              }
            }
          ]
        }
      },
      "variant": {
        "id": 32707,
        "referenceKey": "TC32 BAPIQAZSAP varints1.referenceKey BAPIQA test w Mallory",
        "firstLiveAt": "2023-07-17T14:01:22+00:00",
        "createdAt": "2023-07-17T14:01:04+00:00",
        "updatedAt": "2023-11-09T16:05:56+00:00",
        "stock": {
          "supplierId": 1,
          "warehouseId": 4,
          "quantity": 10,
          "isSellableWithoutStock": false
        },
        "price": {
          "currencyCode": "EUR",
          "withTax": 800,
          "withoutTax": 672,
          "recommendedRetailPrice": 1000,
          "tax": {
            "vat": {
              "amount": 128,
              "rate": 0.19
            }
          },
          "appliedReductions": [
            {
              "category": "sale",
              "type": "relative",
              "amount": {
                "relative": 0.2,
                "absoluteWithTax": 200
              }
            }
          ],
          "reference": {
            "withoutTax": 84,
            "withTax": 100,
            "size": 100,
            "unit": "ml"
          }
        },
        "customData": {
          "subscriptionEligibility": false,
          "deliveryEstimate": []
        }
      },
      "product": {
        "id": 16934,
        "isActive": true,
        "isSoldOut": false,
        "isNew": false,
        "createdAt": "2023-07-17T14:01:04+00:00",
        "updatedAt": "2023-08-17T10:49:55+00:00",
        "indexedAt": "2023-11-23T10:09:32+00:00",
        "firstLiveAt": "2023-07-17T14:01:21+00:00",
        "masterKey": "TC32 BAPIQAZSAP master.referenceKey BAPIQA test w Mallory",
        "referenceKey": "TC32 BAPIQAZSAP referenceKey BAPIQA test w Mallory",
        "images": [
          {
            "hash": "images/084dace7d7ff691e97982fa554113c29"
          }
        ],
        "customData": {
          "subscriptionDiscountSubsequentPercentage": 10,
          "wedwde": "Prepearation for ppk w 'promotionKey': null,",
          "productCustomData": "productCustomData",
          "subscriptionIntervals": "[\"1 month\", \"3 month\", \"6 month\", \"12 month\"]",
          "subscriptionEligibility": false
        }
      },
      "itemGroup": null,
      "promotionId": null,
      "promotion": null
    }
  ],
  "packages": [
    {
      "carrierKey": "zelim-test",
      "deliveryDate": {
        "max": "2023-11-27",
        "min": "2023-11-24"
      },
      "id": 1
    },
    {
      "carrierKey": "zelim-test",
      "deliveryDate": {
        "max": "2023-11-27",
        "min": "2023-11-24"
      },
      "id": 2
    }
  ],
  "cost": {
    "currencyCode": "EUR",
    "withTax": 10400,
    "withoutTax": 8740,
    "recommendedRetailPrice": null,
    "tax": {
      "vat": {
        "amount": 1660,
        "rate": 0
      }
    },
    "appliedReductions": [
      {
        "category": "sale",
        "type": "relative",
        "amount": {
          "relative": 0.15,
          "absoluteWithTax": 2000
        }
      },
      {
        "category": "promotion",
        "type": "relative",
        "amount": {
          "relative": 0.05,
          "absoluteWithTax": 600,
          "absoluteTax": 100,
          "absoluteWithoutTax": 500
        }
      }
    ]
  }
}

Delete basket item

To delete an item from the basket we simply need to pass the item key.

currently for deleteItem() in NodeJS SDK the basket object is not nested under the key basket but included directly. This will be fixed in the next upcoming version

ParameterTypeRequiredDescription
basketKeystringtrueUnique identifier of the basket.
withBasketWithfalseDefines which optional fields should be included in the response. Contained as with inside the options object (second parameter).
// Get a basket item and delete it
const { basket } = await client.basket.get("myshop_customer_1234");
console.log(`Items count: ${basket.items.length}`);
// Items count: 1

const item = basket.items[0];
const response = await client.basket.deleteItem(
  "myshop_customer_1234",
  item.key
);
console.log(`Items count: ${response.items.length}`); // Note that items are directly included in response
// Items count: 0
Response
{
  "key": "myshop_customer_1234",
  "items": [],
  "packages": [],
  "cost": {
    "currencyCode": "EUR",
    "withTax": 0,
    "withoutTax": 0,
    "recommendedRetailPrice": null,
    "tax": { "vat": { "amount": 0, "rate": 0 } },
    "appliedReductions": []
  }
}