Conversations about creating, managing, and using metafields to store and retrieve custom data for apps and themes.
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 %}
<div class="description rte" itemprop="description">
<b>Material Color:</b> {{ product.metafields.global.attribute.material-color }}
</div>
{% 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 %}<b>Colour:</b> {{ field | last }}<br />{% 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'] }}
That worked. Thank you so much! I was having a lot of trouble with this.