--- title: Discount Function Settings API description: >- This API is available to Discount Function Settings extensions. Refer to the [tutorial](/docs/apps/build/discounts/build-ui-extension) for more information. Note that the [`FunctionSettings`](/docs/api/admin-extensions/components/forms/functionsettings) component is required to build Discount Function Settings extensions. api_version: 2026-01 api_name: admin-extensions source_url: html: >- https://shopify.dev/docs/api/admin-extensions/latest/target-apis/contextual-apis/discount-function-settings-api md: >- https://shopify.dev/docs/api/admin-extensions/latest/target-apis/contextual-apis/discount-function-settings-api.md --- # Discount Function Settings API This API is available to Discount Function Settings extensions. Refer to the [tutorial](https://shopify.dev/docs/apps/build/discounts/build-ui-extension) for more information. Note that the [`FunctionSettings`](https://shopify.dev/docs/api/admin-extensions/components/forms/functionsettings) component is required to build Discount Function Settings extensions. ## apply​Metafield​Change(**[change](#applymetafieldchange-propertydetail-change)**​) Applies a change to the discount function settings. ### Parameters * **change** **MetafieldChange** **required** ### Returns * **Promise\** ### MetafieldChange ```ts MetafieldUpdateChange | MetafieldRemoveChange ``` ### MetafieldUpdateChange * key ```ts string ``` * namespace ```ts string ``` * type ```ts 'updateMetafield' ``` * value ```ts string | number ``` * valueType ```ts SupportedDefinitionType ``` ### SupportedDefinitionType ```ts 'boolean' | 'collection_reference' | 'color' | 'date' | 'date_time' | 'dimension' | 'file_reference' | 'json' | 'metaobject_reference' | 'mixed_reference' | 'money' | 'multi_line_text_field' | 'number_decimal' | 'number_integer' | 'page_reference' | 'product_reference' | 'rating' | 'rich_text_field' | 'single_line_text_field' | 'product_taxonomy_value_reference' | 'url' | 'variant_reference' | 'volume' | 'weight' | 'list.collection_reference' | 'list.color' | 'list.date' | 'list.date_time' | 'list.dimension' | 'list.file_reference' | 'list.metaobject_reference' | 'list.mixed_reference' | 'list.number_decimal' | 'list.number_integer' | 'list.page_reference' | 'list.product_reference' | 'list.rating' | 'list.single_line_text_field' | 'list.url' | 'list.variant_reference' | 'list.volume' | 'list.weight' ``` ### MetafieldRemoveChange * key ```ts string ``` * namespace ```ts string ``` * type ```ts 'removeMetafield' ``` ### MetafieldChangeResult ```ts MetafieldChangeSuccess | MetafieldChangeResultError ``` ### MetafieldChangeSuccess * type ```ts 'success' ``` ### MetafieldChangeResultError * message ```ts string ``` * type ```ts 'error' ``` ## data The object exposed to the extension that contains the discount function settings. * **id** **string** **required** The unique identifier for the discount. * **metafields** **Metafield\[]** **required** The discount metafields. ### Metafield * description ```ts string ``` * id ```ts string ``` * key ```ts string ``` * namespace ```ts string ``` * type ```ts string ``` * value ```ts string ``` ## discounts The reactive API for managing discount function configuration. * **discountClasses** **ReadonlySignalLike\** **required** A signal that contains the discount classes. * **discountMethod** **ReadonlySignalLike\** **required** A signal that contains the discount method. * **updateDiscountClasses** **UpdateSignalFunction\** **required** A function that updates the discount classes. ### ReadonlySignalLike Represents a reactive signal interface that provides both immediate value access and subscription-based updates. Enables real-time synchronization with changing data through the observer pattern. * subscribe Subscribes to value changes and calls the provided function whenever the value updates. Returns an unsubscribe function to clean up the subscription. Use to automatically react to changes in the signal's value. ```ts (fn: (value: T) => void) => () => void ``` * value The current value of the signal. This property provides immediate access to the current value without requiring subscription setup. Use for one-time value checks or initial setup. ```ts T ``` ### DiscountClass ```ts 'product' | 'order' | 'shipping' ``` ### DiscountMethod ```ts 'automatic' | 'code' ``` ### UpdateSignalFunction A function that updates a signal and returns a result indicating success or failure. The function is typically used alongisde a ReadonlySignalLike object. * value ```ts T ``` Result\ ```ts Result ``` ### Result A result type that indicates the success or failure of an operation. ```ts {success: true; value: T} | {success: false; errors: ValidationError[]} ``` ### ValidationError A validation error object that is returned when an operation fails. * code A code identifier for the error. ```ts string ``` * issues Field-level validation issues ```ts { message: string; path: string[]; }[] ``` * message A message describing the error. ```ts string ``` * type ```ts 'error' ```