Cart V2
Update cart item
Changed onUpdate cart item quantity
Updates a cart item's quantity or variant selection by:
- Validating cart item exists and belongs to user
- If quantity updated: validating new quantity against availability
- If variant changed: validating new variant and checking availability
- Updating price_per_unit to current price
- Updating cart item record
Quantity must be positive. To remove an item, use DELETE endpoint instead. Changing variant will update the price to the new variant's current price.
Requirements:
- 31.1: PUT /api/v2/cart/:id endpoint
- 31.2: Accept quantity and variant_id updates
- 31.3: Validate cart item exists and belongs to user
- 31.4: Validate new quantity against variant availability
- 31.5: Validate new variant_id if provided
- 31.6: Update price_per_unit to current price
- 31.7: Prevent quantity from being set to 0 (use DELETE instead)
- 31.8: Use database transaction for atomicity
- 31.9: Return 404 if cart item not found
- 31.10: Return 403 if cart item belongs to different user
- 31.11: Log cart modifications to audit trail
- 31.12: Invalidate cart cache after update
put/cart/{id}
Request
- Base URL: /api/v2 (relative, and the document was published on a file host, not at the API’s origin)
- URL: /api/v2/cart/{id}
- Auth: loggedin (a scheme the document does not define)
Path parameters
idstring required
Cart item UUID
Request body
Response
Success message
Changes
- ○
the endpoint scheme security
loggedinwas added to the API - ○
the endpoint scheme security
jwtwas removed from the API
- ○