Metafields not displaying in product.liquid

We had a third party import values as metafields into shopify. I’m trying to use the metafields on our product.liquid page but they’re not displaying. Here’s an example of the code:

{% if product.metafields.global.attribute.material-color %}

Material Color: {{ product.metafields.global.attribute.material-color }}
{% endif %}

The name space is: global
Key is: attribute.material-color

Is it because of the period in the key? All the values that were transfered used that format; attribute.NAME.

Reference: https://help.shopify.com/themes/liquid/objects/metafield

I use a simple call which just uses the namespace:

{% for field in product.metafields.mColour %}Colour: {{ field | last }}
{% endfor %}

  • Mike

If you need to grab a specific metafield with a period in the name you can do so like this:

{{ product.metafields.global['attribute.material-color'] }}
1 Like

That worked. Thank you so much! I was having a lot of trouble with this.