Parameters
NoneReturns
ShopifyCart | null
Returns null if the cart has not been initialized.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Get the full cart state
openbridge.cart.get()
ShopifyCart | null
Returns null if the cart has not been initialized.
const cart = openbridge.cart.get()
if (cart) {
console.log('Cart ID:', cart.id)
console.log(
'Total:',
cart.cost.totalAmount.amount,
cart.cost.totalAmount.currencyCode
)
console.log('Items:', cart.totalQuantity)
}
function updateCartTotals() {
const cart = openbridge.cart.get()
if (cart) {
document.querySelector('.subtotal').textContent =
`${cart.cost.subtotalAmount.currencyCode} ${cart.cost.subtotalAmount.amount}`
document.querySelector('.total').textContent =
`${cart.cost.totalAmount.currencyCode} ${cart.cost.totalAmount.amount}`
}
}
const cart = openbridge.cart.get()
const isEmpty = !cart || cart.totalQuantity === 0
if (isEmpty) {
showEmptyCartMessage()
}
.subscribe().