Skip to main content

shopify:cart:view

Fires when a buyer opens the cart, either as a page or as a drawer. The context field tells you which.

You can use this to act when a buyer is reviewing what they're about to buy. The event carries the full cart, so you don't need a follow-up request to read it.

A view-event custom element dispatches it, so a storefront wires it up in Liquid rather than in JavaScript. A drawer inside a <dialog> fires on open without needing a trigger attribute. See dispatching view events.

cart is null when no cart has been created yet, which is different from a cart that exists and is empty.

Anchor to context
context
'page' | 'dialog'
required

Whether the buyer opened the cart page or a cart drawer.

| null
required

The cart as it appears to the buyer. This is null when no cart has been created yet.

Anchor to detail
detail
Record<string, unknown>

Optional custom data for the storefront's internal use. Listeners can read it.


Was this page helpful?