MetafieldsMetafields Overview

Metafields Overview

PromoSync copies supplier data that Shopify has no standard field for into metafields on your products and variants: tier prices, minimum quantities, decoration locations, specifications, packaging and more. Your theme reads them to build tier pricing tables, decoration pickers and spec sheets.

{% raw %}{{ product.metafields.psrestful.brand }}
{{ product.metafields.psrestful.minimum_quantity }}
{% assign tiers = product.selected_or_first_available_variant.metafields.psrestful.part_price_array.value %}{% endraw %}

Namespaces

NamespaceWhat’s in itWho gets it
psrestfulSupplier product data, tier pricing, decoration dataEvery shop
mm-google-shoppingGoogle Merchant Center fieldsShops with the Merchandising bundle (see Google Merchant Fields)

Metafield Categories

Product Metafields

Fields on the product: supplier code and product ID, brand, line name, minimum quantity, lead time, decoration locations, materials, compliance flags, marketing points.

Variant Metafields

Fields on each variant: Part ID, GTIN, tier pricing, dimensions, apparel size, specifications, colors, packaging, and the per-variant image gallery.

Google Merchant Fields

Fields for Google Shopping: category, brand, condition, age group, gender, material, custom labels, and per-variant GTIN, MPN, color, size, title and cost.

Quick Reference

Most Used Metafields

MetafieldLevelTypeDescription
part_price_arrayVariantJSONTier prices: [{quantityMin, price}], price in cents
minimum_quantityProductIntegerMinimum order quantity
location_decorationsProductJSONDecoration locations and methods
brandProductTextBrand name
supplier_codeProductTextPromoStandards supplier code
color_arrayVariantJSONSupplier color data (name, standard color, hex, PMS)
specification_arrayVariantJSONMeasurements and other specifications

Google Merchant Fields

FieldNamespace and keyDescription
Brandmm-google-shopping.brandProduct brand
GTINmm-google-shopping.gtin (variant)Barcode
MPNmm-google-shopping.mpn (variant)Supplier Part ID
Conditionmm-google-shopping.conditionAlways new

Accessing Metafields in Liquid

Basic Access

{% raw %}{% assign brand = product.metafields.psrestful.brand %}
{% if brand %}
  <span class="product-brand">{{ brand }}</span>
{% endif %}{% endraw %}

JSON Metafields

For JSON metafields, read .value to get the parsed data:

{% raw %}{% assign locations = product.metafields.psrestful.location_decorations.value %}
{% for location in locations %}
  <p>{{ location.locationName }}: {{ location.decorations.size }} methods</p>
{% endfor %}{% endraw %}

Variant Metafields

{% raw %}{% assign colors = variant.metafields.psrestful.color_array.value %}
{% for color in colors %}
  <span style="background: {{ color.hex | default: '#ccc' }};">{{ color.colorName }}</span>
{% endfor %}{% endraw %}

Namespaces with a hyphen

Use bracket notation for mm-google-shopping:

{% raw %}{{ product.metafields['mm-google-shopping'].brand }}{% endraw %}

Accessing Metafields via API

Storefront API

The Storefront API only returns metafields whose definition has storefront access. PromoSync turns it on for the definitions the storefront scripts need: part_price_array, setup_tier_array, method_slug, charge_kind, default_variant_id, and the opt-in msrp and msrp_min. For any other key, turn on storefront access yourself (see Metafield Definitions). Liquid can read every metafield without it.

query VariantPricing($productHandle: String!) {
  product(handle: $productHandle) {
    variants(first: 10) {
      edges {
        node {
          id
          metafield(namespace: "psrestful", key: "part_price_array") {
            value
          }
        }
      }
    }
  }
}

Admin API

query {
  product(id: "gid://shopify/Product/123456") {
    metafields(first: 50, namespace: "psrestful") {
      edges {
        node {
          key
          value
        }
      }
    }
  }
}

Metafield Definitions

PromoSync creates the metafield definitions for you. When you open the app, it checks whether your store has every definition it needs and adds the missing ones in the background. It does the same before an import or a metafield update writes values. You can also run it by hand with Create Metafields in the title bar of the PromoSync settings pages.

To see the definitions in Shopify:

  1. Go to Settings > Metafields and metaobjects in your Shopify admin
  2. Click Products or Variants
  3. Look for the psrestful (and, on Merchandising shops, mm-google-shopping) definitions

A few definitions only appear when a setting needs them: msrp and msrp_min when Save MSRP Metafields is on, and the mm-google-shopping fields when the shop has the Merchandising bundle.

When Metafields Are Written

ActionWhat it writes
Product importAll metafields that have data
Update MetafieldsRewrites the product and variant metafields from current supplier data
Update Pricespart_price_array, cost per item, and the Google COGS field
Update InventoryNo metafields. It updates Shopify inventory levels

Common Use Cases

1. Display Tier Pricing

Show quantity breaks and pricing on product pages. See Storefront Widgets or the no-code PromoSync Tier Pricing block.

2. Decoration Options

Show available imprint locations and methods. See Location Decorations or the PromoSync Decorations block.

3. Google Shopping Feed

Send product data to Google Merchant Center. See Google Merchant Fields.

4. Filters and Smart Collections

product_id is filterable in the Shopify admin product list. With Save MSRP Metafields on, msrp and msrp_min can be used in automated collection rules.

Troubleshooting

Metafield Not Showing

  1. Check that the product was imported or linked by PromoSync (it has psrestful.extra_id)
  2. Check the namespace: psrestful, or mm-google-shopping for Google fields
  3. Check that the definition exists under Settings > Metafields and metaobjects
  4. For the Storefront API, check the definition’s storefront access
  5. Some keys are only written when the supplier provides the data

Data Is Outdated

Run Update Metafields on the product, or Update Prices for tier prices only.

JSON Values

Read .value to get parsed JSON. Without it you get the raw string:

{% raw %}{% comment %} Parsed JSON {% endcomment %}
{% assign data = product.metafields.psrestful.location_decorations.value %}
 
{% comment %} Raw JSON string {% endcomment %}
{% assign raw = product.metafields.psrestful.location_decorations %}{% endraw %}

Next Steps