Skip to main content

shopify:cart:error

Fires when a cart operation fails, such as an add to cart that the cart rejects.

You can use this to tell a failure from an operation that's still running, so an optimistic update rolls back rather than staying on screen.

You dispatch it from the same element as the operation that failed. Without an eventTarget, an action dispatches it from document.

This event reaches every listener, which is how an app learns about a failure it didn't cause. It fires only when the request itself failed, and the promise of that operation rejects at the same time. A cart that declines a change isn't a failure: the promise resolves with userErrors and no error event.

Anchor to error
error
string
required

A human-readable message describing what failed. Don't parse this. Branch on code instead.

required

The reason the operation failed. Branch on this rather than on error.

Anchor to detail
detail
Record<string, unknown>

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


Was this page helpful?