Skip to main content

shopify:cart:discount-update

Fires when a buyer applies or removes a discount code.

You can use this to see which codes buyers try, or to react when a code your app owns is applied.

discountCodes is the complete set the cart should end up with, not a delta, so send every code the buyer should have and send an empty array to clear them all. The resolved cart reports which of them the cart accepted.

You dispatch it from the discount form, when the buyer submits and before the result is known. A code the cart won't apply still resolves the promise, and the matching discountCodes entry comes back with applicable: false. A failed request rejects the promise and dispatches shopify:cart:error.

Anchor to discountCodes
discountCodes
[]
required

The full set of codes the cart should end up with. This replaces the existing codes rather than adding to them, so send an empty array to clear them all.

Anchor to promise
promise
Promise<>
required

Resolves with a CartDiscountUpdateResult when the update finishes. It rejects if the request fails or is aborted.

Anchor to detail
detail
Record<string, unknown>

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


Was this page helpful?