Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
I have created a text metafield list called ingredients and I want to loop through it in liquid.
The problem is when I do {{ product.metafields.info.ingredients }}, it gives me a result
["Lorem Ipsum is simply dummy text of the printing.","Lorem Ipsum 2 is simply dummy text of the printing.","Lorem Ipsum 3 is simply dummy text of the printing.","Lorem Ipsum 4 is simply dummy text of the printing."]
But when I try to loop through it like this
{% for ingredient in product.metafields.info.ingredients %}
<li>{{ ingredient }}</li>
{% endfor %}
It doesn't output anything. Any idea what I am doing wrong? Please help.
Solved it.
I was missing value in the for loop.
The correct syntax is
{% for ingredient in product.metafields.info.ingredients.value %}
<li>{{ ingredient }}</li>
{% endfor %}
YOU SAVED MY NIGHT!!! Thanks 🙂
Thank you! Burnt up an hour trying everything to get the output.
Was missing the .value also
This has totally helped, but now i have another wrinkle. I want each item in the metafield array (which are separated by commas) to link to a search of that item. But what I'm getting is a link to both items. I don't think it is treating my metafield like an array. Is that something i needed to do when defining the metafield?
This is my code:
{% for movieactors in product.metafields.custom.movieactors.value %}
<a href="/search?q={{ movieactors }}" >{{ movieactors }}</a>
{% endfor %}
Thanks in advanced for any help you (or anyone else!) can provide.
Thanksss 🤙
<img src="d">
As 2024 wraps up, the dropshipping landscape is already shifting towards 2025's trends....
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024In today’s interview, we sat down with @BSS-Commerce to discuss practical strategies f...
By JasonH Nov 13, 2024