Metaobjects values in metafields for date time list.

Metaobjects values in metafields for date time list.

Adina3
Visitor
3 0 3

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!

Replies 2 (2)

Niki_K
Shopify Partner
449 46 126

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!

 

Send me a link to your store to niki@ecommercepot.com and I'll help you out.
For more info what I do, visit my agency website ecommercepot.com or my personal website nikikozak.me.

slasw7
Shopify Partner
13 0 0

I had the same problem, turned out the metaobjects were in "Draft" state.

Change them the "Active" state and your code would work.