Cart
Manage the authenticated customer's shopping cart, update item quantities, and calculate cart checkout totals.
Authentication
All Cart endpoints require Bearer JWT access token authentication for a registered CUSTOMER account:
Cart Endpoints Overview
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| POST | /api/v1/carts |
Add product or variant to cart | Bearer JWT |
| GET | /api/v1/carts |
Retrieve cart items (Paginated) | Bearer JWT |
| GET | /api/v1/carts/summary |
Retrieve cart summary with estimated tax & subtotal | Bearer JWT |
| PUT | /api/v1/carts/update |
Update product quantity in cart (0 removes item) | Bearer JWT |
| DELETE | /api/v1/carts/remove |
Remove specific product from cart | Bearer JWT |
| DELETE | /api/v1/carts/all |
Clear entire shopping cart | Bearer JWT |
Endpoint Details
1. Add Product to Cart
Adds an item line to the authenticated user's cart. If the product has variants (e.g. Size, Color), variantId must be supplied.
Request Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
productId |
string | Required | UUID of the product to add |
quantity |
integer | Required | Quantity to add (must be positive, e.g. >= 1) |
variantId |
string | Conditional | UUID of the selected variant. Mandatory if the product has variants. |
Request Examples
Response
2. Get Cart Items
Retrieves all line items currently saved in the customer's shopping cart.
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
page / offset |
integer | Optional | Page number (default: 1) or offset (default: 0) |
perPage / limit |
integer | Optional | Items per page (default: 10, max: 100) |
Request Examples
Response
[
{
"productId": "71b26dd9-b4b5-4f87-a84d-c8daa506018a",
"quantity": 3,
"product": {
"id": "71b26dd9-b4b5-4f87-a84d-c8daa506018a",
"categoryId": "58f5c085-d04a-47de-beab-1d476b6ce432",
"productName": "Smart Watch",
"productCode": "SW-001",
"productQuantity": 5,
"productDetail": "Xiaomi Smart Watch",
"price": 10.0,
"discountPrice": 0.0,
"status": "ACTIVE"
}
}
]
3. Update Cart Item Quantity
Sets the absolute quantity of an item in the cart. Setting quantity: 0 automatically removes the item line.
Request Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
productId |
string | Required | UUID of the product |
quantity |
integer | Required | New absolute quantity (>= 0) |
variantId |
string | Optional | Variant identifier if updating a variant line |
Request Examples
Response
4. Remove Product from Cart
Removes an item line completely from the customer's cart.
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
productId |
string | Required | UUID of the product to remove |
variantId |
string | Optional | UUID of the variant line to remove |
Request Examples
Response
5. Clear Cart
Empties all lines from the customer's shopping cart.
Request Examples
Response
6. Get Cart Summary
Calculates variant-aware subtotals, item counts, available stock, and estimated taxation.
Request Examples
Response
{
"items": [
{
"productId": "71b26dd9-b4b5-4f87-a84d-c8daa506018a",
"productName": "Smart Watch",
"price": 10.0,
"quantity": 3,
"image": "https://example.com/image1.jpg",
"stockQuantity": 50,
"shopId": "shop-uuid-1",
"shopName": "Electronics Shop"
}
],
"subtotal": 30.0,
"estimatedTax": 3.0,
"itemCount": 1
}
Error Handling
Standard Error Responses
For details on error schemas, validation failure formats, and HTTP status codes (400, 401, 404), see the Error Handling & Status Codes Guide.