Delete All Cart
Completely removes an existing cart from the system.
HTTP Method & Endpoint
DELETE | /cart/{cartId}
Request
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
cartId | String | Yes | Unique identifier of the cart to delete |
Response Format
Success Response (200 OK)
| Field | Type | Description |
|---|---|---|
message | String | Status message indicating the result of the operation |
data | Object | Empty object |
source | String | Source of the operation (e.g., "db") |
Examples
JavaScript (React)
import axios from "axios";
import { api } from "../constant";
const deleteCart = async (cartId) => {
try {
const response = await api.delete(`/cart/${cartId}`);
console.log("Cart deleted successfully:", response.data);
} catch (error) {
console.error("Error deleting cart:", error.response?.data || error.message);
}
};
// Example usage
deleteCart("cart_PhIidALwQ8JFCBOU");
Sample Response
{
"message": "Cart Deleted Successfully",
"data": {},
"source": "db"
}
Error Responses
| Status Code | Description |
|---|---|
| 400 | Bad Request - Invalid cart ID format |
| 401 | Unauthorized - Authentication token is missing or invalid |
| 403 | Forbidden - User does not have permission to delete this cart |
| 404 | Not Found - Cart with the specified ID was not found |
| 500 | Internal Server Error - Something went wrong on the server |
Notes
- This operation permanently deletes the cart and all its items. This action cannot be undone.
- If you want to empty a cart but keep the cart itself, consider using the Remove Item endpoint for all items instead.