I’m working with dawn and wanted to show more details in form of metadata about my products at the collection page in the product grid, for example length or package content. Is there a way to edit the product grid in order to be able to add metafields?
Topic summary
A user working with the Dawn theme wants to display product metafields (such as package length or content) in the product grid on collection pages.
Solution provided:
- Create custom metafield definitions in Shopify admin (Settings → Metafields → Product)
- Navigate to Online Store → Theme → Edit code
- Locate the
card-product.liquidsnippet file - Add Liquid code to display metafields using the format:
{{ card_product.metafields[namespace][key] }}(e.g.,{{ card_product.metafields.package.length }}) - Remember to add metafield data to individual products in the admin panel
Key correction: Initially suggested using product.metafields, but this was corrected to card_product.metafields to properly reference the product object within the card snippet.
The issue was resolved after implementing the corrected code syntax.
-
follow these article to add metafield
https://help.shopify.com/en/manual/metafields/metafield-definitions/creating-custom-metafield-definitions -
Go to Online Store->Theme->Edit code
-
snippets/card-product.liquid
-
after that change namespace and key with code below
{{ product.metafields.[namespace].[key] }}
ex: {{ product.metafields.package.length}}
{{ product.metafields.package.content}}
5. Copy code that you’ve updated above after that paste it to where you would like to show it.
thanks for answering!
I followed every step, but it wount show any metafields data
do I have to tag it rightly?
Hi,
Could you please go to Settings->Metafields-> Product after that take a screenshot? It will like the screenshot below:
The code below will show data of inspired_by metafield. Namespace: custom. Key: inspired_by
{{ card_product.metafields.custom.inspired_by}}
And remember go to admin products → select product to add data to each field.
Hope can help.
EBOOST
Hi,
Sorry. It should be replace product to card_product like code below:
{{ card_product.metafields.custom.inspired_by}}
Hope can help.
EBOOST
hey,
yes that helped thanks!
Jocki
