Skip to main content
Declare additional Shopify metafields you want Swish to fetch alongside product and variant data. Once preloaded, metafield values are available on product.metafields and variant.metafields (keyed by namespace, then by key) and are passed to transforms, intents, and view sections.
Each entry is a namespace.key string. Metafields are loaded with the rest of the product data, so they are available the moment the product is rendered.

Reading a metafield value

Metafields are exposed as a nested record keyed by namespace, then by key. Any namespace you declared in metafields.product or metafields.productVariant is always present (as {} when no values are set), so you only need optional chaining at the namespace level for namespaces you didn’t declare.
For namespaces that contain special characters (for example, app-reserved namespaces like $app:swish), use bracket access:
Values are always strings. Cast or parse them as needed for non-string types (numbers, JSON, references).

Using metafields in transforms

Metafields pair naturally with transforms when you want to override how a product is displayed based on data in your Shopify admin.

Using metafields in intents

You can also read metafields from intent callbacks like saveProduct.promptVariantIfMissing:
Only declare the metafields you actually use. Each entry adds a field to the Shopify Storefront API query, which counts against your storefront cost budget.

Further reading