Skip to main content

Discounts
API

The API for interacting with discounts.

The base API object provided to purchase extension targets.

StatefulRemoteSubscribable<[]>
required

Discounts that have been applied to the entire cart.

StatefulRemoteSubscribable<[]>
required

A list of discount codes currently applied to the checkout.

Was this section helpful?

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.

Was this section helpful?

Anchor to useApplyDiscountCodeChange
useApplyDiscountCodeChange()

Returns a function to add or remove discount codes.

(change: ) => Promise<>
Was this section helpful?

Anchor to useDiscountAllocations
useDiscountAllocations()

Returns the current discount allocations applied to the cart.

[]
Was this section helpful?

Anchor to useDiscountCodes
useDiscountCodes()

Returns the current discount codes applied to the cart.

[]
Was this section helpful?