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:
Key | Type | Description |
---|---|---|
reset | Boolean | A boolean query parameter that can be used to reset the cart before adding the new item to it. |
items | Array | An array of objects, where each object represents an item in the cart. |
نصيحة
To remove an item from the cart, you can simply set the amount of that item to 0.
Item Sku Object
Key | Type | Description |
---|---|---|
sku | string | The unique SKU identifier of the item. |
amount | Integer | The quantity of the item in the cart. |
{
"reset": true,
"items": [
{
"sku": 127431,
"amount": 1
}
]
}
معلومات
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:
Key | Type | Description |
---|---|---|
reset | Boolean | A boolean query parameter that can be used to reset the cart before adding the new item to it. |
items | Array | An array of objects, where each object represents an item in the cart. |
نصيحة
To remove an item from the cart, you can simply set the amount of that item to 0.
Item Id Object
Key | Type | Description |
---|---|---|
id | string | The unique identifier of the item. |
amount | Integer | The quantity of the item in the cart. |
{
"reset": true,
"items": [
{
"id": 127431,
"amount": 1
}
]
}
نصيحة
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:
Key | Type | Description |
---|---|---|
grand_total | Integer | The total amount of the items in the cart, including any applicable discounts, or shipping fees. |
can_checkout | Boolean | A 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. |
items | Array | An 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. |
gifts | Array | An array that stores any gifts or promotional items associated with the cart. These items are typically added based on specific promotions or customer actions. |
suggestions | Integer | An array that provides suggestions or recommendations for additional products that the user may consider adding to the cart from promotion. |
isApplied | Boolean | A 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
}
}
معلومات
Check the following section to learn more about the Add to Cart By Item ID API Reference