Hi all,
Is there a way to add a meta field to the product cards on the collection page? I was hoping to add it above the price or alongside it. Picture for reference. Thanks in advance.
Main Issue:
Users want to display product metafields on collection page product cards, typically above or alongside the price.
Solution Provided:
card-product.liquid theme file{% render 'price', product: card_product, price_class: '' %}{{ card_product.metafields.custom.fieldname }}Common Issues & Fixes:
card_product (not product_card_product)| metafield_text filter to remove [" "] characters around text valuescard-product.liquid; the file might use a different naming convention depending on the themeStatus:
Multiple users confirmed the solution works. Questions remain about theme-specific file locations and CSS styling for the displayed metafields.
Hi all,
Is there a way to add a meta field to the product cards on the collection page? I was hoping to add it above the price or alongside it. Picture for reference. Thanks in advance.
Hi @atacox2 ,
Please follow these steps:
Online Store => Themes => Edit code
Find the file card-product.liquid
Find the code
{% render 'price', product: card_product, price_class: '' %}
{{ card_product.metafields.custom.tex }}
The above code will display the “tex” metafield
Result:
Note:
With metafield product.metafields.custom.tex will correspond to the code when added to the card-product.liquid file is {{ card_product.metafields.custom.tex }}
I’m inputting the below and did so with .tex and neither worked
{%- endif -%}
{% render ‘price’, product: product_card_product, price_class: ‘’ %}
{{ card_product.metafields.CAcademy.course_hours.text }}
Am I missing something?
Hi @atacox2 ,
Make sure that you have written the metafield correctly.
You can watch the video to see how:
DEV Thuyen NA Store · Products · 5 Pocket Jean · Shopify - 11 July 2023 (loom.com)
This was a huge help! Thank you!
Hello. What do you do if you don’t have a product card liquid in your theme? I’m trying to do the same thing but not having any luck.
I have created some product metafields I want added under the product title in the product collection list.
Hi there, I know I’m late to this thread but it is still very relevant!
I have used your code to add in my meta field to the product card however it was added it in with [" "] around the text used in the metafield - is there a way to remove this? Also, how would I go about styling this with CSS?
For the nesting special characters, I have found the solution in another thread for anyone looking for it:
{{ card_product.metafields.custom.fragrance | metafield_text }}
could this file be called something else as unable to locate this in the charge theme - thanks