Preload Shopify metafields onto products and variants so you can read them from transforms, intents, and views.
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.
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.
const value = product.metafields.custom?.material;
For namespaces that contain special characters (for example, app-reserved namespaces like $app:swish), use bracket access:
const value = product.metafields["$app:swish"]?.setup;
Values are always strings. Cast or parse them as needed for non-string types (numbers, JSON, references).
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.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Swish Docs","colors":{"primary":"#16A34A","light":"#07C983","dark":"#15803D"},"logo":{"light":"https://mintcdn.com/swish/b_f2_-vYUeM92N84/images/swish-logo-light.svg?fit=max\u0026auto=format\u0026n=b_f2_-vYUeM92N84\u0026q=85\u0026s=1ea7a11a92f8392f8b68a63879a4d5b7","dark":"https://mintcdn.com/swish/b_f2_-vYUeM92N84/images/swish-logo-dark.svg?fit=max\u0026auto=format\u0026n=b_f2_-vYUeM92N84\u0026q=85\u0026s=8522ffa1bcaf8ad27fa5456b74f93894"},"favicon":"https://mintcdn.com/swish/C4mnUD6ibIVf3UOt/images/favicon.png?fit=max\u0026auto=format\u0026n=C4mnUD6ibIVf3UOt\u0026q=85\u0026s=ba111d9b652ae8fc67edd5d5ce313f36","navbar":{"links":[{"href":"mailto:support@swish.app","label":"Support"}],"primary":{"type":"button","label":"Dashboard","href":"https://swish.app"}},"footer":{"socials":{}},"icons":{"library":"lucide"},"contextual":{"options":["copy","view","chatgpt","claude","perplexity","mcp","cursor","vscode"],"display":"header"},"styling":{"latex":false},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"swish","hasAudioNarration":false,"actualSubdomain":"swish","customDomains":["swish.app"],"gitSource":{"type":"github","owner":"swish-app","repo":"swish","deployBranch":"main","contentDirectory":"apps/docs","isPrivate":true,"mountPath":"","label":""},"feedback":{"thumbs":false},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6af3374f8b1d48fe4630c3ab","clientVersion":"0.0.4102","searchFilterCounts":[{"language":"default","tag":"References","count":61},{"language":"default","tag":"REST API","count":47},{"language":"default","tag":"Guides","count":41},{"language":"default","tag":"Customize","count":25},{"language":"default","tag":"Views","count":12},{"language":"default","tag":"Integrations","count":11},{"language":"default","tag":"Swish SDK","count":11},{"language":"default","tag":"Platforms","count":9},{"language":"default","tag":"Items","count":8},{"language":"default","tag":"Lists","count":8}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableAskAiSearchBar":true,"deflection":{"enabled":true,"email":"support@swish.app","showHelpButton":true}},"basePath":"/docs","hasChatPermissions":true,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[],"page":{"pagePath":"guides/customize/metafields","slug":"/guides/customize/metafields","pageMetadata":{"title":"Metafields","description":"Preload Shopify metafields onto products and variants so you can read them from transforms, intents, and views.","href":"/guides/customize/metafields"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Preload Shopify metafields onto products and variants so you can read them from transforms, intents, and views.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,p:`p`,pre:`pre`,span:`span`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Table,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Table)_missingMdxReference(`Table`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`Declare additional Shopify metafields you want Swish to fetch alongside product and variant data. Once preloaded, metafield values are available on `,_jsx(_components.code,{children:`product.metafields`}),` and `,_jsx(_components.code,{children:`variant.metafields`}),` (keyed by namespace, then by key) and are passed to `,_jsx(_components.a,{href:`/guides/customize/transforms`,children:`transforms`}),`, `,_jsx(_components.a,{href:`/guides/customize/intents`,children:`intents`}),`, and view sections.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`6`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`6`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`window`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`SwishOptions`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` metafields:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` product:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"custom.material\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"custom.care_instructions\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`],`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` productVariant:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"custom.weight\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`],`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`};`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Each entry is a `,_jsx(_components.code,{children:`namespace.key`}),` string. Metafields are loaded with the rest of the product data, so they are available the moment the product is rendered.`]}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Option`}),_jsx(_components.th,{children:`Type`}),_jsx(_components.th,{children:`Default`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`product`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`string[]`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`[]`})}),_jsx(_components.td,{children:`Product metafields to fetch.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`productVariant`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`string[]`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`[]`})}),_jsx(_components.td,{children:`Variant metafields to fetch.`})]})]})]}),`\n`,_jsx(Heading,{level:`2`,id:`reading-a-metafield-value`,children:`Reading a metafield value`}),`\n`,_jsxs(_components.p,{children:[`Metafields are exposed as a nested record keyed by namespace, then by key. Any namespace you declared in `,_jsx(_components.code,{children:`metafields.product`}),` or `,_jsx(_components.code,{children:`metafields.productVariant`}),` is always present (as `,_jsx(_components.code,{children:`{}`}),` when no values are set), so you only need optional chaining at the namespace level for namespaces you didn’t declare.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` value`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` product`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`metafields`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`custom`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`?.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`material`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`For namespaces that contain special characters (for example, app-reserved namespaces like `,_jsx(_components.code,{children:`$app:swish`}),`), use bracket access:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` value`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` product`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`metafields`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"$app:swish\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]?.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`setup`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`Values are always strings. Cast or parse them as needed for non-string types (numbers, JSON, references).`}),`\n`,_jsx(Heading,{level:`2`,id:`using-metafields-in-transforms`,children:`Using metafields in transforms`}),`\n`,_jsxs(_components.p,{children:[`Metafields pair naturally with `,_jsx(_components.a,{href:`/guides/customize/transforms`,children:`transforms`}),` when you want to override how a product is displayed based on data in your Shopify admin.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`8`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`8`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`window`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`SwishOptions`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` metafields:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` product:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"swish.price_label\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`],`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` transforms:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` productPrice`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ({ `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`product`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` product`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`?.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`metafields`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`swish`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`?.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`price_label`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`};`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`using-metafields-in-intents`,children:`Using metafields in intents`}),`\n`,_jsxs(_components.p,{children:[`You can also read metafields from intent callbacks like `,_jsx(_components.code,{children:`saveProduct.promptVariantIfMissing`}),`:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`11`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`11`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`window`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`SwishOptions`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` metafields:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` product:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"custom.skip_variant_select\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`],`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` intents:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` saveProduct:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` promptVariantIfMissing`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ({ `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`product`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` product`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`metafields`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`custom`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`?.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`skip_variant_select`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` !==`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"true\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`};`})}),`\n`]})})}),`\n`,_jsx(Warning,{children:_jsx(_components.p,{children:`Only declare the metafields you actually use. Each entry adds a field to the\nShopify Storefront API query, which counts against your storefront cost\nbudget.`})}),`\n`,_jsx(Heading,{level:`2`,id:`further-reading`,children:`Further reading`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`/guides/customize/transforms`,children:`Transforms`}),` for customizing how product data is rendered`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`/guides/customize/intents`,children:`Intents`}),` for behavior callbacks that can read metafields`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`/references/sdk/configuration`,children:`Configuration reference`}),` for all SDK options`]}),`\n`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Metafields","description":"Preload Shopify metafields onto products and variants so you can read them from transforms, intents, and views.","href":"/guides/customize/metafields"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Reading a metafield value","slug":"reading-a-metafield-value","depth":2,"children":[]},{"title":"Using metafields in transforms","slug":"using-metafields-in-transforms","depth":2,"children":[]},{"title":"Using metafields in intents","slug":"using-metafields-in-intents","depth":2,"children":[]},{"title":"Further reading","slug":"further-reading","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"swish","siteName":"Swish Docs","title":"Metafields - Swish Docs","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-05-21T16:22:26.229Z","originalFileLocation":"guides/customize/metafields.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Preload Shopify metafields onto products and variants so you can read them from transforms, intents, and views.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Swish Docs\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/docs/mintlify-assets/_mintlify/favicons/swish/2hSkz4L8UUOTHj7K/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/docs/mintlify-assets/_mintlify/favicons/swish/2hSkz4L8UUOTHj7K/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/docs/mintlify-assets/_mintlify/favicons/swish/2hSkz4L8UUOTHj7K/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/docs/mintlify-assets/_mintlify/favicons/swish/2hSkz4L8UUOTHj7K/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/docs/mintlify-assets/_mintlify/favicons/swish/2hSkz4L8UUOTHj7K/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/docs/mintlify-assets/_mintlify/favicons/swish/2hSkz4L8UUOTHj7K/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/docs/mintlify-assets/_mintlify/favicons/swish/2hSkz4L8UUOTHj7K/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/docs/mintlify-assets/_mintlify/favicons/swish/2hSkz4L8UUOTHj7K/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/docs/mintlify-assets/_mintlify/favicons/swish/2hSkz4L8UUOTHj7K/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Metafields - Swish Docs\">\u003cmeta data-mint-head property=\"og:description\" content=\"Preload Shopify metafields onto products and variants so you can read them from transforms, intents, and views.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Swish Docs\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://swish.app/docs/guides/customize/metafields\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://swish.mintlify.site/docs/_mintlify/api/og/v2?division=Customize\u0026amp;title=Metafields\u0026amp;description=Preload+Shopify+metafields+onto+products+and+variants+so+you+can+read+them+from+transforms%2C+intents%2C+and+views.\u0026amp;theme=78172bc158e2cb768d270e02\u0026amp;signature=478e3f49fc341c03a95842a04678616b55ab52118257e7349bd6eb7d4e389ccd\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Metafields - Swish Docs\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Preload Shopify metafields onto products and variants so you can read them from transforms, intents, and views.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://swish.mintlify.site/docs/_mintlify/api/og/v2?division=Customize\u0026amp;title=Metafields\u0026amp;description=Preload+Shopify+metafields+onto+products+and+variants+so+you+can+read+them+from+transforms%2C+intents%2C+and+views.\u0026amp;theme=78172bc158e2cb768d270e02\u0026amp;signature=478e3f49fc341c03a95842a04678616b55ab52118257e7349bd6eb7d4e389ccd\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/docs/mintlify-assets/_mintlify/favicons/swish/2hSkz4L8UUOTHj7K/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Swish Docs\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#16A34A\">\u003clink data-mint-head rel=\"canonical\" href=\"https://swish.app/docs/guides/customize/metafields\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/docs/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/docs/guides/customize/metafields.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://swish.app/#organization\",\"name\":\"Swish Docs\",\"url\":\"https://swish.app\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/swish/b_f2_-vYUeM92N84/images/swish-logo-light.svg?fit=max\u0026auto=format\u0026n=b_f2_-vYUeM92N84\u0026q=85\u0026s=1ea7a11a92f8392f8b68a63879a4d5b7\"}},{\"@type\":\"WebSite\",\"@id\":\"https://swish.app/docs#website\",\"name\":\"Swish Docs\",\"url\":\"https://swish.app/docs\",\"publisher\":{\"@id\":\"https://swish.app/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://swish.app/docs/guides/customize/metafields#webpage\",\"url\":\"https://swish.app/docs/guides/customize/metafields\",\"name\":\"Metafields\",\"description\":\"Preload Shopify metafields onto products and variants so you can read them from transforms, intents, and views.\",\"dateModified\":\"2026-05-21T16:22:26.229Z\",\"isPartOf\":{\"@id\":\"https://swish.app/docs#website\"},\"breadcrumb\":{\"@id\":\"https://swish.app/docs/guides/customize/metafields#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://swish.app/docs/guides/customize/metafields#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Customize\",\"item\":\"https://swish.app/docs/guides/customize/overview\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Metafields\",\"item\":\"https://swish.app/docs/guides/customize/metafields\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://swish.app/docs/guides/customize/metafields#article\",\"headline\":\"Metafields\",\"name\":\"Metafields\",\"description\":\"Preload Shopify metafields onto products and variants so you can read them from transforms, intents, and views.\",\"url\":\"https://swish.app/docs/guides/customize/metafields\",\"mainEntityOfPage\":{\"@id\":\"https://swish.app/docs/guides/customize/metafields#webpage\"},\"dateModified\":\"2026-05-21T16:22:26.229Z\",\"publisher\":{\"@id\":\"https://swish.app/#organization\"},\"isPartOf\":{\"@id\":\"https://swish.app/docs#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Swish Docs\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Swish Docs\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/docs/guides/customize/metafields.md","siteName":"Swish Docs","nav":{"global":null,"tabs":[{"tab":"Guides","groups":[{"group":"Get started","icon":"rocket","pages":[{"title":"Overview","href":"/guides/get-started/overview"},{"title":"Quickstart","href":"/guides/get-started/quickstart"},{"title":"Migration guide","href":"/guides/get-started/migration"},{"title":"Moving to the new admin","href":"/guides/get-started/new-admin"}]},{"group":"Features","icon":"puzzle","pages":[{"title":"Wishlist","href":"/guides/features/wishlist"},{"title":"Save from cart","href":"/guides/features/save-from-cart"},{"title":"Recently viewed","href":"/guides/features/recently-viewed"},{"title":"Notifications","href":"/guides/features/notifications"},{"title":"Orders","href":"/guides/features/orders"},{"title":"Account","href":"/guides/features/account"}]},{"group":"Customize","icon":"paint-bucket","pages":[{"title":"Overview","href":"/guides/customize/overview"},{"title":"Full defaults","href":"/guides/customize/defaults"},{"group":"Appearance","pages":[{"title":"Design","href":"/guides/customize/appearance/design"},{"title":"Icons","href":"/guides/customize/appearance/icons"},{"title":"Custom CSS","href":"/guides/customize/appearance/css"}]},{"group":"Placements","pages":[{"title":"Placements overview","href":"/guides/customize/placements/overview"},{"title":"Header","href":"/guides/customize/placements/header"},{"title":"Collections","href":"/guides/customize/placements/collections"},{"title":"Product detail","href":"/guides/customize/placements/product-detail"}]},{"group":"Views","pages":[{"title":"Views overview","href":"/guides/customize/views/overview"},{"title":"Drawer","href":"/guides/customize/views/drawer"},{"title":"Home","href":"/guides/customize/views/home"},{"title":"Saves","href":"/guides/customize/views/saves"},{"title":"Lists","href":"/guides/customize/views/lists"},{"title":"List detail","href":"/guides/customize/views/list-detail"},{"title":"Product detail","href":"/guides/customize/views/product-detail"},{"title":"Orders","href":"/guides/customize/views/orders"},{"title":"Order detail","href":"/guides/customize/views/order-detail"},{"title":"Profile","href":"/guides/customize/views/profile"},{"title":"Notifications","href":"/guides/customize/views/notifications"},{"title":"List detail page","href":"/guides/customize/views/list-detail-page"}]},{"title":"Intents","href":"/guides/customize/intents"},{"title":"Transforms","description":"Customize how product, variant, and option data is displayed in the Swish UI.","href":"/guides/customize/transforms"},{"title":"Metafields","href":"/guides/customize/metafields"},{"title":"Translations","description":"Customize or translate any text in the Swish UI by overriding translation keys.","href":"/guides/customize/translations"}]},{"group":"Headless","icon":"terminal","pages":[{"title":"Overview","href":"/guides/headless/overview"},{"title":"Auth proxy","href":"/guides/headless/auth-proxy"},{"title":"Hydrogen","href":"/guides/headless/hydrogen"},{"title":"Next.js","href":"/guides/headless/nextjs"}]},{"group":"AI tools","icon":"sparkles","pages":[{"title":"Cursor","href":"/ai-tools/cursor"},{"title":"Claude","href":"/ai-tools/claude-code"}]}]},{"tab":"Integrations","pages":[{"title":"Integrations","href":"/integrations/overview"}]},{"tab":"References","menu":[{"item":"Swish SDK","icon":"code","pages":[{"title":"Swish SDK","href":"/references/sdk/overview"}]},{"item":"React SDK","icon":"atom","pages":[{"title":"React SDK","href":"/references/react/overview"}]},{"item":"REST API","icon":"square-terminal","pages":[{"title":"REST API","href":"/references/api/overview"}]}],"pages":[{"title":"References","href":"/references/sdk/overview"}]},{"tab":"Changelog","pages":[{"title":"Changelog","href":"/changelog"}]}]},"basePath":"","title":"Metafields - Swish Docs","buildId":"dpl_2AK98Hxhwu4fUXpx9atbv41cC328","deploymentId":"dpl_2AK98Hxhwu4fUXpx9atbv41cC328","dynamics":[],"chunks":[]}