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.

Discount Function Settings API

Requires the FunctionSettings component.

The Discount Function Settings API lets you build UI extensions that provide custom configuration interfaces for discount functions. Use this API to create settings pages for Shopify Functions that implement discount logic.

  • Discount configuration: Build settings interfaces for discount Shopify Functions.
  • Metafield storage: Store discount function configuration in metafields with proper validation.
  • Settings UI: Create custom configuration experiences for discount logic and rules.
  • Function integration: Configure Shopify Functions that implement custom discount behavior.
Support
Targets (1)

Updates or removes metafields that store discount function configuration data. Accepts a change object with the operation type, key, namespace, value, and value type.

Anchor to change
change
required

Promise<>

The data object exposed to the extension containing the discount function settings. Provides access to the discount identifier and associated metafields that store function configuration values. Use this data to populate your settings UI and understand the current function configuration in the admin.discount-details.function-settings.render target.

required

The discount being configured by the merchant. Use this ID to associate configuration changes with the correct discount.

Anchor to metafields
metafields
[]
required

An array of metafields that store the discount function's configuration values. Use these metafields to populate your settings UI with the current discount configuration and display existing settings to merchants.


  • Check operation result type: applyMetafieldChange returns { type: 'success' } or { type: 'error', message: string }. Errors don't throw exceptions, so always check the returned type property.

  • Metafields are subject to size limits. Individual metafield values can't exceed 256KB, and total metafields per resource have storage limits.
  • The applyMetafieldChange method is sequential. Operations are processed one at a time. Rapid successive calls might lead to race conditions where new updates overwrite earlier ones.
  • Metafield changes are applied immediately. Unlike some admin forms, metafield changes persist right away without waiting for the merchant to save the discount.

Was this page helpful?