Display Collection Metafield on Product Page

Mo_Tayeb
New Member
3 0 0

Hi,

I am trying to display a collection metafield on a product page. We have setup collections for vendors. In the collections metafields we have placed a field for video URLs. I have tried to call this field on the collections page in the following method:

 {{ collections.metafields.video.video-url }} 

but this does not work!

I am also trying to call this video URL on the product pages of said vendor. I have tried the following method but it's not working:

{% capture vendor_collection %}{{ product.vendor | handleize }}{% endcapture %}  

{{ collections[vendor_collection].metafields.video.video-url }}

Any help would be greatly appreciated.

Replies 5 (5)
Jason
Shopify Expert
10438 168 2081

{{ collections.metafields.video.video-url }}
...but this does not work!

Nor should it. There reference should be like this:

{{ collections.collection-name.metafields.namespace.key }} 

Also double check your namespaces and spelling. Seen plenty of examples of people saying metafields are not working only to find out it was just a typo.

This bit of code...

{{ collections[vendor_collection].metafields.video.video-url }}

... assumes that the vendor_collection string matches an existing collection handle. Does it?

I jump on these forums to help and share some insights. Not looking to be hired, and not looking for work.
Don't hand out staff invites or give admin password to forum members unless absolutely needed. In most cases the help you need can be handled without that.
★ http://freakdesign.com.au ★
Mo_Tayeb
New Member
3 0 0

Thanks, Jason - yes the vendor_collection string matches an existing collection handle. How would you advise me to go about displaying it?

Mo_Tayeb
New Member
3 0 0

Any help would be appreciated

Jason
Shopify Expert
10438 168 2081

If you are 100% sure that you are referencing the metafield correctly, it's time to check and make sure you are setting the metafield correctly in the first place. How are you setting the metafield? Double check the namespace and key name to ensure you've not added a rogue typo.

I jump on these forums to help and share some insights. Not looking to be hired, and not looking for work.
Don't hand out staff invites or give admin password to forum members unless absolutely needed. In most cases the help you need can be handled without that.
★ http://freakdesign.com.au ★
aderbas
New Member
2 0 0

Thanks for the explanation on how to properly reference the fields. 

 

The follow-up question now is, how do I get the liquid template to reference multiple collections at once. The reason for this is I've got a tab where I place my ingredients disclaimer message, and I want to place the same place the same message on every product on a collection by collection basis. how do I use the one tab, to reference the same metafield that is used in multiple collections? 

 

Hopefully the question is clear. 

 

Thanks,