Skip to content

Add To Basket

Add a product variant to the user's shopping basket or update quantity if already exists.

Endpoint

PUT /v1/products/basket/

Authentication

Required (User role)

Query Parameters

Parameter Type Required Description
currency_id integer No Currency ID for price conversion

Request Body

{
  "product_variant_id": 10,
  "quantity": 2
}

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)

{
  "error": "Product Not Found"
}

Insufficient Stock (400)

{
  "error": "Not enough stock available for this product"
}

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_id is provided
  • discount_percent is the discount percentage (0 if no discount)
  • discount_price is the final price after discount (calculated from converted price if currency_id is provided)
  • Basket items are user-specific