Skip to main content

updateCart

Adds, updates, or removes cart lines, sets the cart note, and applies discount codes. A single call can do more than one of these.

You can use this instead of posting to the cart yourself, so your app doesn't need to know how the cart is rendered. A storefront that configures this action refreshes its own UI. Without a configuration, the default refreshes the cart on themes it recognizes, and reloads the page on themes it doesn't.

A line with merchandiseId is an add, a line with id is an update, and quantity: 0 removes it.

The call emits the matching cart events as it starts, so they fire whether or not the change succeeds. The lines and note events carry a context of standard-action unless you set another. A rejected change resolves with userErrors rather than throwing, so check that array before reading cart.

Adds, updates, or removes cart lines, sets the cart note, or applies discount codes. The call emits the matching cart events as it starts, so they fire whether or not the change succeeds.

Anchor to payload
payload
required
Anchor to options
options

Promise<>

Was this page helpful?