Parameters
Single item
Multiple items
Returns
Promise<ShopifyCart>
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Update cart item quantities
openbridge.cart.update(lineId, quantity)
openbridge.cart.update(lines)
| Param | Type | Required | Description |
|---|---|---|---|
lineId | string | Yes | Cart line ID |
quantity | number | Yes | New quantity |
| Param | Type | Required | Description |
|---|---|---|---|
lines | CartLineUpdateInput[] | Yes | Array of updates |
Promise<ShopifyCart>
const lines = openbridge.cart.lines()
await openbridge.cart.update(lines[0].id, 5)
const lines = openbridge.cart.lines()
await openbridge.cart.update([
{ id: lines[0].id, quantity: 2 },
{ id: lines[1].id, quantity: 4 }
])
document
.querySelector('.quantity-input')
.addEventListener('change', async (e) => {
const lineId = e.target.dataset.lineId
const quantity = parseInt(e.target.value)
if (quantity > 0) {
await openbridge.cart.update(lineId, quantity)
}
})
async function updateQuantity(lineId, delta) {
const line = openbridge.cart.lines().find((l) => l.id === lineId)
const newQuantity = line.quantity + delta
if (newQuantity > 0) {
await openbridge.cart.update(lineId, newQuantity)
} else {
await openbridge.cart.remove(lineId)
}
}
.remove() instead.