Skip to main content
Migrate to Polaris

Version 2025-07 is the last API version to support React-based UI components. Later versions use web components, native UI elements with built-in accessibility, better performance, and consistent styling with Shopify's design system. Check out the migration guide to upgrade your extension.

Discounts API

The API for interacting with discounts.

The base API object provided to purchase extension targets.

Anchor to discountAllocations
discountAllocations
StatefulRemoteSubscribable<[]>
required

Discounts that have been applied to the entire cart.

Anchor to discountCodes
discountCodes
StatefulRemoteSubscribable<[]>
required

A list of discount codes currently applied to the checkout.

The API object provided to purchase.checkout extension targets.

Anchor to applyDiscountCodeChange
applyDiscountCodeChange
(change: ) => Promise<>
required

Performs an update on the discount codes. It resolves when the new discount codes have been negotiated and results in an update to the value retrieved through the discountCodes property.

Caution

> See security considerations if your extension retrieves discount codes through a network call.

Note

This method will return an error if the cart instruction discounts.canUpdateDiscountCodes is false, or the buyer is using an accelerated checkout method, such as Apple Pay, Google Pay, or Meta Pay.

Anchor to useApplyDiscountCodeChange
useApplyDiscountCodeChange()

Returns a function to add or remove discount codes.

(change: ) => Promise<>

Anchor to useDiscountAllocations
useDiscountAllocations()

Returns the current discount allocations applied to the cart.

[]

Anchor to useDiscountCodes
useDiscountCodes()

Returns the current discount codes applied to the cart.

[]
Was this page helpful?