--- name: shopify-metafields description: Guide for working with Shopify Metafields. Covers definitions, storing custom data, accessing via Liquid, and GraphQL mutations. --- # 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: ```liquid
Washing: {{ product.metafields.my_app.washing_instructions }}
{% assign file = product.metafields.my_app.size_chart.value %}