Cart V2

Update cart item

Changed on

Update cart item quantity

Updates a cart item's quantity or variant selection by:

  1. Validating cart item exists and belongs to user
  2. If quantity updated: validating new quantity against availability
  3. If variant changed: validating new variant and checking availability
  4. Updating price_per_unit to current price
  5. 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

quantitynumber double

New quantity (optional, must be > 0 if provided)

variant_idstring

New variant selection (optional)

Response

Success message

messagestring required

Changes

    • ○

      the endpoint scheme security loggedin was added to the API

    • ○

      the endpoint scheme security jwt was removed from the API