Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

shopify-metafields

БесплатноБез исполняемых скриптовНе проверен

Store custom data on any Shopify resource — products, orders, customers — using typed metafield definitions accessible from Liquid and the Storefront API

finsilabsот finsilabs★ 69 звёзд на GitHub

Об этом скилле

Shopify Metafields

Overview

Metafields let you attach structured custom data to Shopify resources — products, variants, orders, customers, collections, and pages — without building a separate database. Metafield definitions enforce type validation (text, number, date, URL, JSON, file, product reference, etc.) and make metafields available in the Liquid template editor and Storefront API. Metaobjects extend this concept to create reusable, standalone custom data structures.

When to Use This Skill

  • When products need additional attributes beyond Shopify's default fields (care instructions, dimensions, certifications)
  • When storing per-customer data such as loyalty tier, subscription status, or B2B account number
  • When building content-managed sections in a theme using metafield references (FAQs, size guides, feature callouts)
  • When attaching order-level custom data from checkout (gift message, delivery instructions)
  • When creating reusable structured content entries with Metaobjects (team members, press mentions, specs)

Core Instructions

  1. Create metafield definitions via the Admin API

    Definitions enforce type and make metafields storefront-accessible:

    // Create a metafield definition for product care instructions
    const response = await adminClient.request(`
      mutation CreateMetafieldDefinition($definition: MetafieldDefinitionInput!) {
        metafieldDefinitionCreate(definition: $definition) {
          createdDefinition {
            id
            name
            namespace
            key
            type { name }
          }
          userErrors { field message code }
        }
      }
    `, {
      variables: {
        definition: {
          name: "Care Instructions",
          namespace: "custom",
          key: "care_instructions",
          type: "multi_line_text_field",
          ownerType: "PRODUCT",
          description: "Washing and care instructions for the product",
          visibleToStorefrontApi: true,
          // Optional: pin to product admin UI (use pinnedPosition in API version 2023-10+)
          pinnedPosition: 1,
        },
      },
    });
    

    Available types: single_line_text_field, multi_line_text_field, number_integer, number_decimal, date, date_time, boolean, url, json, color, weight, volume, dimension, rating, file_reference, product_reference, variant_reference, collection_reference, page_reference, metaobject_reference, list.<type>.

  2. Write metafields via the Admin API

    // Set a metafield on a product
    export async function setProductMetafield(
      productId: string,
      namespace: string,
      key: string,
      value: string,
      type: string
    ) {
      const response = await adminClient.request(`
        mutation SetMetafield($metafields: [MetafieldsSetInput!]!) {
          metafieldsSet(metafields: $metafields) {
            metafields {
              id key namespace value
            }
            userErrors { field message code }
          }
        }
      `, {
        variables: {
          metafields: [
            {
              ownerId: productId,
              namespace,
              key,
              value,
              type,
            },
          ],
        },
      });
      return response.data.metafieldsSet;
    }
    
    // Example: Set care instructions on a product
    await setProductMetafield(
      "gid://shopify/Product/1234567890",
      "custom",
      "care_instructions",
      "Machine wash cold. Tumble dry low. Do not bleach.",
      "multi_line_text_field"
    );
    
  3. Read metafields in Liquid templates

    Once a definition exists with visibleToStorefrontApi: true, metafields are available in Liquid via the metafields object:

    {% comment %} product.metafields.namespace.key {% endcomment %}
    
    {% if product.metafields.custom.care_instructions != blank %}
      <div class="care-instructions">
        <h3>Care Instructions</h3>
        {{ product.metafields.custom.care_instructions | metafield_tag }}
      </div>
    {% endif %}
    
    {% comment %} Access a product reference metafield {% endcomment %}
    {% assign related = product.metafields.custom.related_product.value %}
    {% if related %}
      <a href="{{ related.url }}">{{ related.title }}</a>
    {% endif %}
    
    {% comment %} Access a list of file references (images) {% endcomment %}
    {% for image in product.metafields.custom.gallery_images.value %}
      <img src="{{ image | image_url: width: 800 }}" alt="{{ image.alt }}">
    {% endfor %}
    
  4. Read metafields via the Storefront API

    // Query product with metafields in the Storefront API
    const { data } = await storefront.request(`
      query GetProductWithMetafields($handle: String!) {
        product(handle: $handle) {
          id
          title
          # Metafields must be explicitly requested by namespace + key
          careInstructions: metafield(namespace: "custom", key: "care_instructions")
    
Полный SKILL.md на GitHub

Установить shopify-metafields в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

claude-code
cursor
gemini-cli
copilot
codex-cli
kiro
opencode

Вложенные файлы

evals/metafield-definitions-and-bulk-write/criteria.jsonevals/metafield-definitions-and-bulk-write/task.mdevals/metaobjects-for-structured-content/criteria.jsonevals/metaobjects-for-structured-content/task.mdevals/storefront-api-metafield-queries/criteria.jsonevals/storefront-api-metafield-queries/task.mdtile.json

FAQ

Что делает скилл shopify-metafields?

Store custom data on any Shopify resource — products, orders, customers — using typed metafield definitions accessible from Liquid and the Storefront API

Как установить скилл shopify-metafields?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл shopify-metafields запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить shopify-metafields с