Skip to main content

Add To Or Remove From Cart

This API allows you to add an item to the customer's cart by providing the item SKU. It will return the updated cart details, including the newly added item.

By Product SKU

  • Endpoint: api/customer/carts/by-sku

  • Http Method: POST

  • Request Body:

KeyTypeDescription
resetBooleanA boolean query parameter that can be used to reset the cart before adding the new item to it.
itemsArrayAn array of objects, where each object represents an item in the cart.
tip

To remove an item from the cart, you can simply set the amount of that item to 0.

Item Sku Object

KeyTypeDescription
skustringThe unique SKU identifier of the item.
amountIntegerThe quantity of the item in the cart.
{
"reset": true,
"items": [
{
"sku": 127431,
"amount": 1
}
]
}
info

Check the following section to learn more about the Add to Cart By Item SKU API Reference

By Product ID

  • Endpoint: api/customer/carts

  • Http Method: POST

  • Request Body:

KeyTypeDescription
resetBooleanA boolean query parameter that can be used to reset the cart before adding the new item to it.
itemsArrayAn array of objects, where each object represents an item in the cart.
tip

To remove an item from the cart, you can simply set the amount of that item to 0.

Item Id Object

KeyTypeDescription
idstringThe unique identifier of the item.
amountIntegerThe quantity of the item in the cart.
{
"reset": true,
"items": [
{
"id": 127431,
"amount": 1
}
]
}
tip

If the reset in request body set to true, the existing items in the cart will be removed and only the new item will be added.

  • Success Response:
KeyTypeDescription
grand_totalIntegerThe total amount of the items in the cart, including any applicable discounts, or shipping fees.
can_checkoutBooleanA boolean value indicating whether the user can proceed to the checkout process. It can be used to determine if the cart meets certain conditions for checkout, such as minimum order requirements.
itemsArrayAn array that holds the cart items. Each item represents a product added to the cart and contains information such as the product ID, quantity, price, and attributes.
giftsArrayAn array that stores any gifts or promotional items associated with the cart. These items are typically added based on specific promotions or customer actions.
suggestionsIntegerAn array that provides suggestions or recommendations for additional products that the user may consider adding to the cart from promotion.
isAppliedBooleanA boolean value indicating whether any promotions or discounts have been applied to the cart.
{
"code": 200,
"data": {
"grand_total": 450,
"can_checkout": true,
"items": [
{
"id": 127431,
"sku": "40702",
"name_en": "Bionike Volume Mascara 8 ml",
"name_ar": "بيونيكيه ماسكارا مكثّفة للرموش 8 مل",
"slug": "bionike-volume-mascara-8-ml-1682774811",
"image": "https://docapi.supercommerce.io",
//...
}
],
"gifts": [],
"suggestions": [],
"isApplied": false
}
}
info

Check the following section to learn more about the Add to Cart By Item ID API Reference