Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hi everyone,
it looks so simple thing but can't get the values of the metaobject when it is selected "List of values".
I thought I have to once again iterate it. But it returns nothing. It is really frustrating debugging when not getting any errors.
{% assign myfields = product.metafields.sp_custom.size_chart_metaobjects.value %} {{ myfields }} // it return MetaobjectDrop {% for m in myfields.sizes %} {{m.value}} //nothing works {{m[0].value}} //nothing works {% endfor %} or {% for m in myfields %} {% for s in myfields.sizes %} {{ s }} //nothing works {{ s.value }} //nothing works {{ s[0].value }} //nothing works {% endfor %} {% endfor %}
this article doesn't help much... https://community.shopify.com/c/technical-q-a/metaobject-values-in-metafields/m-p/1939164
Hi Darius,
Add this to your liquid and send here what you get in your browser console:
<script>{{ myfields | json }}</script>
I have the same issue. Really annoying. You get: "error: json not allowed for this object"
It's an array. ["S", "M", "L"]
@josu24 what about the result of this one?
<script>{{ myfields | json }}</script>
@josu24 what about the result of this one?
<script>{{ myfields.value | json }}</script>
I am having this same issue... can't figure out how to access the list of values correctly. ANy progress?
Give more information on what are you trying to access in your code send that part of your code here!
I did debugging metaobject when it is selected "List of values" below.
It should shows key and value set for size_chart_metaobjects metafield.
product.metafields.sp_custom.size_chart_metaobjects.value | json
So, product's meta fields value can be referred by this code.
product.metafields.sp_custom.size_chart_metaobjects.value['size_chart_metaobjects']
Hope it works for everyone who has been stuck on this issue.
And also, a quick addition;
If you'd like to access a spesific type in this:
product.metafields.sp_custom.size_chart_metaobjects.value['size_chart_metaobjects']
{% for prod in product.metafields.sp_custom.size_chart_metaobjects.value
%}
{{ prod.title }}
{% endfor %}
Thanks a lot, that's also helped me, even the Shopify chatbot also gave the error code, it took my full night.
Amazing! Thank you so much!!! Been stuck on this problem for such a long time!
We recently spoke with Zopi developers @Zopi about how dropshipping businesses can enha...
By JasonH Oct 23, 2024A big shout out to all of the merchants who participated in our AMA with 2H Media: Holi...
By Jacqui Oct 21, 2024We want to take a moment to celebrate the incredible ways you all engage with the Shopi...
By JasonH Oct 15, 2024