shopify-metafields
Shopify Metafields
Metafields allow you to store additional data on Shopify resources (Products, Orders, Customers, Shops) that aren't included in the default schema (e.g., "washing instructions" for a product).
1. Concepts
- Namespace: Grouping folder (e.g.,
my_app,global). - Key: Specific field name (e.g.,
washing_instructions). - Type: Data type (e.g.,
single_line_text_field,number_integer,json). - Owner: The resource attaching the data (Product ID, Shop ID).
2. Metafield Definitions (Standard)
Always use Metafield Definitions (pinned metafields) when possible. This integrates them into the Admin UI and ensures standard processing.
- Create: Settings > Custom Data > [Resource] > Add definition.
- Access:
namespace.key
3. Accessing in Liquid
To display metafield data on the Storefront:
<!-- Accessing a product metafield -->
<p>Washing: {{ product.metafields.my_app.washing_instructions }}</p>
<!-- Accessing a file/image metafield -->
{% assign file = product.metafields.my_app.size_chart.value %}
<img src="{{ file | image_url: width: 500 }}" />
<!-- Checking existence -->
{% if product.metafields.my_app.instructions != blank %}
...
{% endif %}
4. Reading via API (GraphQL)
query {
product(id: "gid://shopify/Product/123") {
title
metafield(namespace: "my_app", key: "instructions") {
value
type
}
}
}
5. Writing via API (GraphQL)
To create or update a metafield, use metafieldsSet.
mutation metafieldsSet($metafields: [MetafieldsSetInput!]!) {
metafieldsSet(metafields: $metafields) {
metafields {
id
namespace
key
value
}
userErrors {
field
message
}
}
}
/* Variables */
{
"metafields": [
{
"ownerId": "gid://shopify/Product/123",
"namespace": "my_app",
"key": "instructions",
"type": "single_line_text_field",
"value": "Wash cold, tumble dry."
}
]
}
6. Private Metafields
If you want data to be hidden from other apps and the storefront, use Private Metafields. Note: These cannot be accessed via Liquid directly.
- Use
privateMetafieldqueries/mutations. - Requires explicit
read_private_metafields/write_private_metafieldsscope (rarely used now,app_datametafields are preferred for app-specific valid storage).
More from toilahuongg/google-antigravity-kit
shopify-liquid
Guide for using the Liquid template language within Shopify Theme App Extensions and Themes. Use this skill when building App Embed Blocks, App Blocks, or modifying Shopify Themes.
50shopify-polaris-design
Design and implement Shopify Admin interfaces using the Polaris Design System. Use this skill when building Shopify Apps, Admin extensions, or any interface that needs to feel native to Shopify.
47docusaurus-generator
Generate end-user documentation site using Docusaurus 3.x from the current project. Use this skill when the user asks to create documentation, generate docs, build a docs site, or set up Docusaurus for their project. Supports analyzing project structure, generating markdown docs, configuring Docusaurus, and creating user guides.
31shopify-remix-template
Guide for developing Shopify apps using the official Shopify Remix Template. Covers structure, authentication, API usage, and deployment.
19remotion-best-practices
Best practices for Remotion - Video creation in React
18remixjs-best-practices
Best practices for Remix (2025-2026 Edition), focusing on React Router v7 migration, server-first data patterns, and error handling.
15