Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Add items to the cart
openbridge.cart.add(variantId, quantity) openbridge.cart.add(variantId, options) openbridge.cart.add(lines)
variantId
string
quantity
number
options.quantity
options.sellingPlanId
lines
CartLineInput[]
Promise<
ShopifyCart
>
await openbridge.cart.add('gid://shopify/ProductVariant/123')
await openbridge.cart.add('gid://shopify/ProductVariant/123', 3)
await openbridge.cart.add([ { merchandiseId: 'gid://shopify/ProductVariant/123', quantity: 2 }, { merchandiseId: 'gid://shopify/ProductVariant/456', quantity: 1 } ])
// After fetching a product const product = await openbridge.products.get('awesome-tshirt') const variant = product.variants[0] await openbridge.cart.add(variant.id, 1)
document.querySelector('.add-to-cart').addEventListener('click', async (e) => { const variantId = e.currentTarget.dataset.variantId const quantity = parseInt(e.currentTarget.dataset.quantity) || 1 await openbridge.cart.add(variantId, quantity) })
await openbridge.cart.add('gid://shopify/ProductVariant/123', { quantity: 1, sellingPlanId: 'gid://shopify/SellingPlan/456' })
await openbridge.cart.add([ { merchandiseId: 'gid://shopify/ProductVariant/123', quantity: 1, sellingPlanId: 'gid://shopify/SellingPlan/456' }, { merchandiseId: 'gid://shopify/ProductVariant/789', quantity: 2 } ])
const lines = openbridge.cart.lines() lines.forEach(line => { if (line.sellingPlanAllocation) { console.log('Plan:', line.sellingPlanAllocation.sellingPlan.name) console.log('Deposit:', line.sellingPlanAllocation.checkoutChargeAmount.amount) console.log('Remaining:', line.sellingPlanAllocation.remainingBalanceChargeAmount.amount) } })