# useApplyDiscountCodeChange Returns a function to add or remove discount codes. > Caution: > See [security considerations](https://shopify.dev/docs/api/checkout-ui-extensions/configuration#network-access) if your extension retrieves discount codes through a network call. ## ### UseApplyDiscountCodeChangeGeneratedType Returns a function to add or remove discount codes. > Caution: > See [security considerations](https://shopify.dev/docs/api/checkout-ui-extensions/configuration#network-access) if your extension retrieves discount codes through a network call. #### Returns: (change: DiscountCodeChange) => Promise export function useApplyDiscountCodeChange< ID extends RenderExtensionPoint = RenderExtensionPoint, >(): (change: DiscountCodeChange) => Promise { const api = useApi(); if ('applyDiscountCodeChange' in api) { return api.applyDiscountCodeChange; } throw new ExtensionHasNoMethodError( 'applyDiscountCodeChange', api.extensionPoint, ); } ### DiscountCodeAddChange ### type value: `"addDiscountCode"` The type of the `DiscountCodeChange` API. ### code value: `string` The code for the discount ### DiscountCodeRemoveChange ### type value: `"removeDiscountCode"` The type of the `DiscountCodeChange` API. ### code value: `string` The code for the discount ### DiscountCodeChangeResultSuccess ### type value: `"success"` Indicates that the discount code change was applied successfully. ### DiscountCodeChangeResultError ### type value: `"error"` Indicates that the discount code change failed. ### message value: `string` 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. ## Related - [StandardApi](https://shopify.dev/docs/api/checkout-ui-extensions/apis/standardapi) - [CheckoutApi](https://shopify.dev/docs/api/checkout-ui-extensions/apis/checkoutapi) - [OrderStatusApi](https://shopify.dev/docs/api/checkout-ui-extensions/apis/orderstatusapi) - [CartLineDetailsApi](https://shopify.dev/docs/api/checkout-ui-extensions/apis/cartlinedetailsapi) - [PickupPointsApi](https://shopify.dev/docs/api/checkout-ui-extensions/apis/pickuppointsapi) - [PickupLocationsApi](https://shopify.dev/docs/api/checkout-ui-extensions/apis/pickuplocationsapi) - [ShippingMethodDetailsApi](https://shopify.dev/docs/api/checkout-ui-extensions/apis/shippingmethoddetailsapi) - [ExtensionPoints](https://shopify.dev/docs/api/checkout-ui-extensions/apis/extensionpoints)