> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openbridge.shop/llms.txt
> Use this file to discover all available pages before exploring further.

# .get()

> Get the full cart state

```javascript theme={null}
openbridge.cart.get()
```

Returns the complete cart object with all data.

## Parameters

None

## Returns

[`ShopifyCart`](/api/types/cart#shopifycart) `| null`

Returns `null` if the cart has not been initialized.

## Examples

### Get cart data

```javascript theme={null}
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)
}
```

### Display cart totals

```javascript theme={null}
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}`
    }
}
```

### Check if cart is empty

```javascript theme={null}
const cart = openbridge.cart.get()
const isEmpty = !cart || cart.totalQuantity === 0

if (isEmpty) {
    showEmptyCartMessage()
}
```

<Tip>
  This is a synchronous method that returns cached cart state. For reactive
  updates, use [`.subscribe()`](/api/cart/subscribe).
</Tip>
