Liquid, JavaScript, themes, sales channels
Hi,
I have a metaobject that contains a list of date time values. I would like these date time values to display on my website as product variants via metafields. The variants dont change price, but the user must select a date time option before checkout.
I have added a liquid code block to the product, but the codes I've tried do not display the correct information
{{product.metafields.hairdresser.availability.value}} returns "MetaobjectListDrop"
{{product.metafields.hairdresser.availability}} returns "["gid://shopify/Metaobject/4145512602"]"
{% for metaobject in product.metafields.hairdresser_profile.values %}
{{ metaobject.availability }}
{{ metaobject.availability.value }}
{% endfor %} does not return anything.
Please help!
Hi @Adina3,
I don't know the entire settings of the metaobject and metafield, so just to give you some guidelines how to use it.
If you're using a list of values, then you need to use the for loop to iterate through all the items in the array. Something like this:
{% for hairdresser in product.metafields.hairdresser_profile.value %}
{{ hairdresser.availability | date: "%a, %b %d, %Y" }}
{% endfor %}
I've recently published an article on how to set up How to display multiple metaobject entries on Shopify?
In the article, you'll find a guide on how to set it up with a real example. Just change the fields (from single line text to date) and you should be able to set it up.
Hope this helps!
I had the same problem, turned out the metaobjects were in "Draft" state.
Change them the "Active" state and your code would work.
User | RANK |
---|---|
36 | |
30 | |
12 | |
11 | |
8 |
On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023You've downloaded the Search & Discovery app from the Shopify App store, and as you're ...
By Skye Nov 8, 2023The year-end shopping season is just around the corner. Is a flash sale on your radar? Are...
By Jasonh Nov 6, 2023