Cart
Get Cart
Retrieve the current user’s cart.
Endpoint
GET /api/cart
Response
- 200 OK: Returns the cart as JSON.
Example Request
GET /api/cartExample Response
{
// ...cart fields...
}Add Item
Add a product to the cart.
Endpoint
POST /api/cart/items
Parameters
product(integer, required): Product ID.quantity(float, required): Quantity to add.- Additional product attributes as needed.
Response
- 200 OK: Cart updated and returned as JSON.
- 400/403/404: Various error conditions (see implementation).
Example Request
POST /api/cart/items
Content-Type: application/x-www-form-urlencoded
product=123&quantity=2Example Response
{
// ...updated cart fields...
}Update Item
Update the quantity of an item in the cart.
Endpoint
PUT /api/cart/items/{itemId}
Parameters
itemId(string, required): The cart item ID.quantity(float, required): New quantity.
Response
- 200 OK: Cart updated and returned as JSON.
- 404 Not Found: If the item does not exist or not authenticated.
Example Request
PUT /api/cart/items/abc123
Content-Type: application/x-www-form-urlencoded
quantity=3Example Response
{
// ...updated cart fields...
}Remove Item
Remove an item from the cart.
Endpoint
DELETE /api/cart/items/{itemId}
Parameters
itemId(string, required): The cart item ID.
Response
- 200 OK: Cart updated and returned as JSON.
- 404 Not Found: If the item does not exist or not authenticated.
Example Request
DELETE /api/cart/items/abc123Example Response
{
// ...updated cart fields...
}Clear Cart
Remove all items from the cart.
Endpoint
DELETE /api/cart
Response
- 200 OK: Cart cleared and returned as JSON.
- 400 Bad Request: If the cart does not exist.
Example Request
DELETE /api/cartExample Response
{
// ...cart fields after clearing...
}Last updated on