How can I pass variable from collection section to product section

Highlighted
New Member
2 0 0

So, I recently made a SIZECHART on my product page through METAFIELD. I put my whole SIZECHART in SHOP metafield so that it can be accessed gloabally from anywhere just like below

Screenshot 2020-09-26 at 1.37.53 PM.png

and I'm accessing this in product page like this

Screenshot 2020-09-26 at 1.47.21 PM.png

And then I wrote code in the product section to and it's working perfectly fine.

PROBLEM: Now, the problem is that instead of adding metafields to each product of the collection one by one. I want it to just put the sizechart to the whole collection so it displays on it's each product. I'm really close to figuring out but the problem is collection metafiled is not accessible to the product section and vice versa, but I want to access the collection's metafield.

Is there a way through which we can access the collection's metafield on the product page? If not then how can we achieve this functionality, is there a workaround or any other tip or trick. Thanks for the answers 

0 Likes
Highlighted
Shopify Partner
1079 170 195

Hi There!

Why don't you create a global metafield for each collection, then on the product page run the following logic:

if Product Is In Collection 1

{

show Collection 1 Metafield

}

elseif Product Is InCollection 2

{

show collection 2 Metafield

}

else

{

something

}

 

- Did we solve your issue? Like & Mark As Solution to help the community
- Should you need any direct help: contact@jhkcreate.com
K&J
0 Likes
Highlighted
New Member
2 0 0

@JHKC thanks for the reply. Hey, can you please elaborate it with an example? it'll be of great help ^_^

 

0 Likes