Liquid, JavaScript, themes, sales channels
Hey guys and girls,
I am trying to read the metafields of a product that is referenced in a LineItem but it does not work.
What I am trying to do:
{{ line_item.product.metafields.global.id }}
But that doesnt work and the metafield does exist 100%!
Is it possible to somehow read the metafields of a product that is referenced in a LineItem?
Thanks for your help
Are you sure a metafield with the key "id" exists? If I recall correctly, Shopify require metafield keys to be at least 3 characters long...
To debug it, put this in your template temporarily to see what metafields are available :
<div hidden>
{% for field in line_item.product.metafields.global %}
--
Key: {{ field | first }}
Value: {{ field | last }}
--
{% endfor %}
</div>
...and then check your source code in the browser. Do you get anything back?
Cheers, Andrew.
Are you ready to take your business to the next level? Look no further than the latest ...
By SarahF_Shopify Apr 15, 2024We’re keeping the ball rolling to make sure you’re always ahead of the game. So buckle ...
By JasonH Apr 8, 2024Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024