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/shopify-agents-kit
shopify-polaris-icons
Guide for using Shopify Polaris Icons in Shopify Apps. Covers icon usage patterns, accessibility, tone variants, and common icon categories for commerce applications.
19email-template-design
Design and build professional HTML email templates with inline CSS for broad email client compatibility. Use this skill when the user asks to create, design, or build email templates, newsletters, transactional emails (order confirmations, receipts, shipping notifications, password resets), marketing emails, welcome series, onboarding emails, abandoned cart emails, drip campaigns, or any HTML email layout. Covers responsive design, dark mode support, and compatibility with Gmail, Outlook (desktop + web), Apple Mail, Yahoo, and mobile clients.
18shopify-extensions
Guide for building and managing Shopify Extensions (Admin, Checkout, Theme, Post-purchase, etc.) using the latest Shopify CLI and APIs.
14shopify-api
Comprehensive guide for Shopify APIs in Remix apps. Covers Admin GraphQL/REST, Storefront API, all resources (products, orders, customers, inventory, collections, discounts, fulfillments, metafields, files), bulk operations, webhooks, resource pickers, and TypeScript patterns. Use when querying/mutating Shopify data or building integrations.
14shopify-polaris-viz
Guide for creating data visualizations in Shopify Apps using the Polaris Viz library. Use this skill when building charts, graphs, dashboards, or any data visualization components that need to integrate with the Shopify Admin aesthetic. Covers BarChart, LineChart, DonutChart, SparkLineChart, and theming.
13code-investigator
Comprehensive code investigation and audit tool. Discovers all project features, then dispatches parallel subagents to analyze issues, risks, dead code, missing functionality, and redundancies. Produces a prioritized risk report. Use this skill when the user asks to "investigate code", "audit project", "find risks", "check code quality", "analyze codebase", "what's wrong with this code", "project health check", "code review entire project", "find dead code", "find redundant code", or any request for a thorough codebase analysis.
11