Skip to main content

Version: v1

Delete All Cart

Completely removes an existing cart from the system.


HTTP Method & Endpoint​

DELETE | /cart/{cartId}


Request​

Path Parameters​

ParameterTypeRequiredDescription
cartIdStringYesUnique identifier of the cart to delete

Response Format​

Success Response (200 OK)​

FieldTypeDescription
messageStringStatus message indicating the result of the operation
dataObjectEmpty object
sourceStringSource 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 CodeDescription
400Bad Request - Invalid cart ID format
401Unauthorized - Authentication token is missing or invalid
403Forbidden - User does not have permission to delete this cart
404Not Found - Cart with the specified ID was not found
500Internal 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.