Change the quantity of a cart item
const url = 'https://acme.mykreezalid.com/front_api/v1/carts/k3v9q2m8x1c7z5b4n6t0p2r8s1d3f7/order_items/4242';const options = { method: 'PUT', headers: {'Content-Type': 'application/json'}, body: '{"quantity":2}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PUT \ --url https://acme.mykreezalid.com/front_api/v1/carts/k3v9q2m8x1c7z5b4n6t0p2r8s1d3f7/order_items/4242 \ --header 'Content-Type: application/json' \ --data '{ "quantity": 2 }'Sets the quantity of one item of the cart (it replaces the quantity, it does not add to it) and recomputes the item’s amount from the price recorded when the item was added. The listing’s available quantity is not checked. Works without a token for a guest cart; a member’s cart only accepts that member’s token. When you send a token and the cart is a guest cart, the cart (and the guest’s other carts and orders) is attached to the signed-in member first.
Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The cart’s url_key, returned when the cart is created.
Example
k3v9q2m8x1c7z5b4n6t0p2r8s1d3f7Id of one of the cart’s items (orders[].order_items[].id in GET /carts/{url_key}).
Example
4242Request Bodyrequired
Section titled “Request Bodyrequired”object
New quantity of the item. To take the item out of the cart, use DELETE on the same path.
Example
2Responses
Section titled “Responses”The quantity was updated.
Outcome of a cart change: status is success when it was applied, failed or error when it was not.
object
Outcome body of the cart endpoints that report status and message.
Human-readable outcome.
Example
{ "status": "success", "message": "Listing updated successfully"}The item could not be saved (status is error).
Outcome of a cart change: status is success when it was applied, failed or error when it was not.
object
Outcome body of the cart endpoints that report status and message.
Human-readable outcome.
Example
{ "status": "success", "message": "Listing updated successfully"}quantity is missing or 0, the item does not exist or does not belong to this cart (with code, status and message), or the cart belongs to a member and the request is not made by that member (with success and error).
Error body returned by the Front API when it refuses a request.
object
HTTP status code, repeated in the body.
Human-readable reason.
Error body returned by several cart endpoints.
object
Error body of the cart endpoints that report success and error.
Human-readable reason.
Example
{ "code": 403, "status": "error", "message": "Token not found in request"}No open cart has this key: it does not exist or is closed.
Error body returned by several cart endpoints.
object
Error body of the cart endpoints that report success and error.
Human-readable reason.
Example
{ "success": false, "error": "Cart not found"}