Skip to main content

shopify:cart:lines-update

Fires when a buyer adds, removes, or updates cart lines. One event covers all three, and the action field tells you which. The context field tells you where it came from, with product, cart, or dialog for a buyer's own interaction, and standard-action when an updateCart call emitted it.

This is the signal that a cart changed, and it replaces watching the DOM or intercepting cart requests. The event fires before the cart is updated, so listeners can show a loading or optimistic state while the operation runs.

You dispatch it from the cart element, or from the product element for adds on a product page.

Because the event fires when the operation starts, it fires whether or not the change succeeds. If the cart declines the change, the promise resolves with the cart as it stands and userErrors explaining why. If the request fails, the promise rejects and shopify:cart:error is dispatched.

Anchor to action
action
'add' | 'remove' | 'update'
required

Whether the lines were added, updated, or removed. This value determines the shape of lines.

Anchor to context
context
'product' | 'cart' | 'dialog' | 'standard-action'
required

Where the update came from. The standard-action value is reserved for events that standard storefront actions emit automatically.

Anchor to lines
lines
[]
required

The cart lines that changed. Contains at least one entry.

Anchor to promise
promise
Promise<>
required

Resolves with a CartLinesUpdateResult when the update finishes. It rejects if the request fails or is aborted, such as on a network error or when a newer update supersedes it.

Anchor to detail
detail
Record<string, unknown>

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


Was this page helpful?