Conversations about creating, managing, and using metafields to store and retrieve custom data for apps and themes.
I am trying to use metafield in my shopify product card code to add custom icons for different products but the metafield code does not seem to work if anyone can help me with this issue
@user123452 I did this on the dawn theme v15. I made a product metafield of type file which allows me to upload photos or videos. And added this code in card-product.liquid file under snippets folder of the code editor.
The line of code: {% if card_product.metafields.custom.image %}
<img src="{{ card_product.metafields.custom.image | image_url }}" alt="Product Image" width="40" height="40">
{% endif %} You can change the alt, width or height as per your liking.
This is how it looks for me.
hope this works out for you or you can send me your theme details. I will be more than happy to look into it. We could iprove the styling and stuff if this works out for you.
Thanks