Remove Item from Cart
Remove a specific product item from an existing cart.
HTTP Method & Endpoint
DELETE | /cart/item
Request
Request Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
cartId | String | Yes | Unique identifier of the cart containing the item |
variantId | String | Yes | ID of the product variant to remove |
Response Format
Success Response (200 OK)
| Field | Type | Description |
|---|---|---|
message | String | Status message indicating the result of the operation |
data | Data | Contains all details about the updated cart |
source | String | Source of the order data (e.g., "db") |
Data Object Properties
| Field | Type | Description |
|---|---|---|
id | String | Unique identifier for the cart |
storeId | String | Store ID for which the cart was created |
customerId | String | Customer's unique identifier |
totalAmount | Number | Total amount payable for the items in the cart |
items | Array(Items) | List of remaining items in the cart |
Items Array Properties
| Field | Type | Description |
|---|---|---|
variantId | String | ID of the product variant |
quantity | Number | Number of units in the cart |
price | Number | Price per unit (in paise) |
Examples
JavaScript (React)
import axios from "axios";
import { api } from "../constant";
const removeItemFromCart = async (cartId, variantId) => {
try {
const response = await api.delete("/cart/item", {
data: {
cartId: cartId,
variantId: variantId,
},
});
console.log("Item removed from cart:", response.data);
} catch (error) {
console.error("Error removing item from cart:", error.response?.data || error.message);
}
};
Sample Response
{
"message": "Cart Item Deleted Successfully",
"data": {
"id": "cart_PhIidALwQ8JFCBOU",
"storeId": "store_Vc3PvYOQrna9GOF7",
"customerId": "customer_123",
"totalAmount": 5000,
"items": [
{
"variantId": "variant_5wLljFpFc8Njgk1o",
"quantity": 50,
"price": 100
}
]
},
"source": "db"
}
Error Responses
| Status Code | Description |
|---|---|
| 400 | Bad Request - Invalid parameters or missing required fields |
| 401 | Unauthorized - Authentication token is missing or invalid |
| 404 | Not Found - Cart or variant not found |
| 500 | Internal Server Error - Something went wrong on the server |
Notes
- This endpoint completely removes the specified variant from the cart. If you wish to decrease the quantity instead, use the Update Cart Item endpoint.
- If the removed item was the last item in the cart, the cart will be empty but still exist in the system.