Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
The goal is to display product metafields on the collection pages, yet calling the following lines of code inside card-product.liquid returns null/blank:
{% if product.metafields.custom.width %} <p>{{ product.metafields.custom.width }}</p> {% endif %}
{{ product.metafields | json }}
How does one enable collections to access product metafields in the Dawn theme?
Below are images of the metafields for namespace info.
Solved! Go to the solution
This is an accepted solution.
The goal is to display metafield data for each product in a collection page. This data is not immediately available. The following solution works:
{% for product in collection.products %}
{% if product.metafields.custom.width.value and product.id == card_product.id %}
<p>{{ product.metafields.custom.width.value }}</p>
{% endif %}
{% endfor %}
Hi @willbeing ,
To better know whether your product section has access to metafields or not, inspect your product in the card-product.liquid file.
{{ product | json }}
If your product is null. It could be because you placed the code in the wrong file or because the name of the product variable is wrong.
If our suggestions are useful, please let us know by giving it a like, marking it as a solution, or donating here ☕.
B2B Solution & Custom Pricing | Product Labels by BSS
Need help from our expert? Kindly share your request with us via community@bsscommerce.com
This is an accepted solution.
The goal is to display metafield data for each product in a collection page. This data is not immediately available. The following solution works:
{% for product in collection.products %}
{% if product.metafields.custom.width.value and product.id == card_product.id %}
<p>{{ product.metafields.custom.width.value }}</p>
{% endif %}
{% endfor %}
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025