Returns a function to add or remove discount codes. > Caution: > See [security considerations](/docs/api/checkout-ui-extensions/configuration#network-access) if your extension retrieves discount codes through a network call.
Returns a function to add or remove discount codes. > Caution: > See [security considerations](/docs/api/checkout-ui-extensions/configuration#network-access) if your extension retrieves discount codes through a network call.
export function useApplyDiscountCodeChange< Target extends RenderExtensionTarget = RenderExtensionTarget, >(): (change: DiscountCodeChange) => Promise<DiscountCodeChangeResult> { const api = useApi<Target>(); if ('applyDiscountCodeChange' in api) { return api.applyDiscountCodeChange; } throw new ExtensionHasNoMethodError( 'applyDiscountCodeChange', api.extension.target, ); }
DiscountCodeAddChange | DiscountCodeRemoveChange
The type of the `DiscountCodeChange` API.
The code for the discount
The type of the `DiscountCodeChange` API.
The code for the discount
DiscountCodeChangeResultSuccess | DiscountCodeChangeResultError
Indicates that the discount code change was applied successfully.
Indicates that the discount code change failed.
A message that explains the error. This message is useful for debugging. It is **not** localized, and therefore should not be presented directly to the buyer.