Update Cart Item
Change quantity or variant of a cart item.
Updated
On this page
Overview
Update the quantity of an item already in the cart.
SDK Usage
import dash from "@/lib/dash"
// Set quantity to 3
await dash.cart.update("size_1g", 3)
The first argument is the sizeId of the item to update. The second is the new quantity.
Note: Setting quantity to 0 effectively removes the item. Use Remove from Cart for explicit removal.
Quantity Selector Example
"use client"
import dash from "@/lib/dash"
export function QuantitySelector({ sizeId, currentQty, onUpdate }) {
async function changeQty(newQty: number) {
if (newQty 1) return
await dash.cart.update(sizeId, newQty)
onUpdate() // Refresh cart display
}
return (
<div className="flex items-center gap-2">
<button onClick={() => changeQty(currentQty - 1)}>-</button>
<span>{currentQty}</span>
<button onClick={() => changeQty(currentQty + 1)}>+</button>
</div>
)
}
REST API
POST /storefront/cart/{cart_id}/update
X-API-Key: pk_live_your_key
Content-Type: application/json
{
"size_id": "size_1g",
"quantity": 3
}
Next Steps
- Remove from Cart — Remove items entirely
- Get Cart — Refresh cart state after updates