SettingsAPI
The API for interacting with merchant settings.
Anchor to standardapiStandardApi
The base API object provided to this and other customer-account
extension targets.
- Anchor to settingssettingsReadonlySignalLike<ExtensionSettings>required
The settings matching the settings definition written in the
shopify.ui.extension.toml
file.See settings examples for more information.
NoteWhen an extension is being installed in the editor, the settings will be empty until a merchant sets a value. In that case, this object will be updated in real time as a merchant fills in the settings.
Docs_Standard_SettingsApi
- settings
The settings matching the settings definition written in the [`shopify.ui.extension.toml`](/docs/api/customer-account-ui-extensions/configuration) file. See [settings examples](/docs/api/customer-account-ui-extensions/apis/order-status-api/settings#examples) for more information. > Note: When an extension is being installed in the editor, the settings will be empty until a merchant sets a value. In that case, this object will be updated in real time as a merchant fills in the settings.
ReadonlySignalLike<ExtensionSettings>
export interface Docs_Standard_SettingsApi
extends Pick<StandardApi, 'settings'> {}
ReadonlySignalLike
Represents a read-only value managed on the main thread that an extension can subscribe to. Example: Checkout uses this to manage the state of an object and communicate state changes to extensions running in a sandboxed web worker. This interface is compatible with Preact's ReadonlySignal: https://github.com/preactjs/signals/blob/a023a132a81bd4ba4a0bebb8cbbeffbd8c8bbafc/packages/core/src/index.ts#L700-L709
- subscribe
(fn: (value: T) => void) => () => void
- value
T
export interface ReadonlySignalLike<T> {
readonly value: T;
subscribe(fn: (value: T) => void): () => void;
}
ExtensionSettings
The merchant-defined setting values for the extension.
- [key: string]
string | number | boolean | undefined
export interface ExtensionSettings {
[key: string]: string | number | boolean | undefined;
}
Accessing merchant settings
Preact
examples
Accessing merchant settings
Preact
import '@shopify/ui-extensions/preact'; import {render} from 'preact'; import {useEffect, useState} from 'preact/hooks'; export default async () => { render(<Extension />, document.body); }; function Extension() { const bannerTitle = shopify.settings.value?.banner_title || ''; return <s-banner title={bannerTitle} />; }
Anchor to examplesExamples
Anchor to example-define-merchant-settingsDefine merchant settings
You can define settings that merchants can edit within the checkout editor. See settings for more information on how to define these.
Define merchant settings
shopify.extension.toml
examples
Define merchant settings
description
You can define settings that merchants can edit within the checkout editor. See [settings](/docs/api/customer-account-ui-extensions/configuration#settings-definition) for more information on how to define these.
shopify.extension.toml
api_version = "unstable" [[extensions]] name = "My customer account ui extension" handle = "customer-account-ui" type = "ui_extension" [[extensions.targeting]] target = "customer-account.order-status.block.render" module = "./Extension.jsx" [extensions.settings] [[extensions.settings.fields]] key = "banner_title" type = "single_line_text_field" name = "Banner title" description = "Enter a title for the banner." [[extensions.settings.fields.validations]] name = "min" value = "5" [[extensions.settings.fields.validations]] name = "max" value = "20"