Add To Basket
Add a product variant to the user's shopping basket or update quantity if already exists.
Endpoint
Authentication
Required (User role)
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
currency_id |
integer | No | Currency ID for price conversion |
Request Body
Parameters
| Field | Type | Required | Description |
|---|---|---|---|
product_variant_id |
integer | Yes | ID of the product variant |
quantity |
integer | Yes | Quantity to add (will add to existing if item already in basket) |
Response
Success (200 OK)
{
"id": 5,
"product": {
"id": 10,
"product_id": 5,
"name_az": "Məhsul Adı",
"name_en": "Product Name",
"sku": "SKU-001",
"stock_quantity": 100,
"price": 29.99,
"discount_percent": 10.0,
"discount_price": 26.99,
"currency_name": "AZN",
"attributes": [...],
"images": [...],
"is_wish": false,
"created": "2025-01-15T10:30:00Z"
},
"quantity": 3
}
Note: If the item already exists in the basket, the quantity is added to the existing quantity.
Error Responses
Product Not Found (404)
Insufficient Stock (400)
This error occurs when: - Adding new item: requested quantity exceeds available stock - Updating existing item: new total quantity exceeds available stock
Example Request
curl -X PUT "https://api.luxmart.site/v1/products/basket/?currency_id=1" \
-H "Authorization: Token your_access_token" \
-H "Content-Type: application/json" \
-d '{
"product_variant_id": 10,
"quantity": 2
}'
Notes
- If item already exists in basket, quantity is added (not replaced)
- Stock quantity is checked before adding
- Price is converted to specified currency if
currency_idis provided discount_percentis the discount percentage (0 if no discount)discount_priceis the final price after discount (calculated from converted price ifcurrency_idis provided)- Basket items are user-specific