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.
Remove items from the cart
openbridge.cart.remove(lineId)
openbridge.cart.remove(lineIds)
| Param | Type | Required | Description |
|---|---|---|---|
lineId | string | Yes | Cart line ID |
| Param | Type | Required | Description |
|---|---|---|---|
lineIds | string[] | Yes | Array of line IDs |
Promise<ShopifyCart>
const lines = openbridge.cart.lines()
await openbridge.cart.remove(lines[0].id)
const lines = openbridge.cart.lines()
const idsToRemove = lines.slice(0, 2).map((l) => l.id)
await openbridge.cart.remove(idsToRemove)
document.querySelectorAll('.remove-item').forEach((button) => {
button.addEventListener('click', async () => {
const lineId = button.dataset.lineId
await openbridge.cart.remove(lineId)
})
})
const productHandle = 'awesome-tshirt'
const lines = openbridge.cart.lines()
const linesToRemove = lines
.filter((line) => line.merchandise.product.handle === productHandle)
.map((line) => line.id)
if (linesToRemove.length > 0) {
await openbridge.cart.remove(linesToRemove)
}
.clear() instead.