Solved

How to display title, image etc. from product meta field?

phillip12
Shopify Partner
16 2 7

I'm trying to display the products I saved in a meta field on my product detail page, but all I get it is:

["GID://SHOPIFY/PRODUCT/7978216456473","GID://SHOPIFY/PRODUCT/7978217177369","GID://SHOPIFY/PRODUCT/7978217537817","GID://SHOPIFY/PRODUCT/7978217570585"] How can I render these products? I'm using the Dawn Theme.

Bildschirmfoto 2022-11-24 um 11.01.40.png

 

 

Accepted Solution (1)
phillip12
Shopify Partner
16 2 7

This is an accepted solution.

I got it working

 

I solved this by adding .value

{% for recommended_product in product.metafields.custom.styled_with.value %}
    {{ recommended_product.title }}
  {% endfor %} 

View solution in original post

Replies 6 (6)

kaalTechGeeks
Shopify Partner
300 57 76

Hi @phillip12
you can extract each and every data of the product from the metafield using the product object of shopify. 
You can take help of the product object doc of shopify to get a better idea on how you can extract the information: https://shopify.dev/api/storefront/2022-10/objects/product 

NOTE: for this you need to have good coding knowledge of shopify liquid, else you can hire a developer for this work. 
Thanks & Regards 
  

- If my answers saved you time and headaches, consider buying me a coffee!
- Check my profile: KaalTechGeeks | Reach out to me on my socials - Instagram | Skype | Mail
- Was my reply helpful? Click Like to let me know! & if your question was answered, Mark it as an Accepted Solution!
phillip12
Shopify Partner
16 2 7

Thanks. Do I have to use a query or something to get the product information based on the GID's?

kaalTechGeeks
Shopify Partner
300 57 76

No on liquid everything is based on handles. 
You just need to add liquid expressions to extract the values. 
for ex: {{ product.title }} would return product title
{{ product.description }} would return the description

- If my answers saved you time and headaches, consider buying me a coffee!
- Check my profile: KaalTechGeeks | Reach out to me on my socials - Instagram | Skype | Mail
- Was my reply helpful? Click Like to let me know! & if your question was answered, Mark it as an Accepted Solution!
phillip12
Shopify Partner
16 2 7

I want to display the product information of the products I saved as a metafield, but all I get are GID's... How can I get the product information based on the GID's?

phillip12
Shopify Partner
16 2 7

This is an accepted solution.

I got it working

 

I solved this by adding .value

{% for recommended_product in product.metafields.custom.styled_with.value %}
    {{ recommended_product.title }}
  {% endfor %} 
imabhijithak
Shopify Partner
3 0 0

what if i have a ''product-card'' snippet , with all product name , image styled already, is their any way i could use that snippet to display the product instead like printing one by one by using " {{ recommended_product.title }} "