Showing Custom Metafields On Collection / Product Card (Dawn Theme)

I have posted about this before and could never solve the issue. I have a bunch of customer metafields for products and want to show them in other places sometimes.

In this case on the Collection page (product-card.liquid) so I find where I want it and type “Test” and save to make sure I am editing the right file. I am.

Then I put in the metafield liquid:

{{ product.metafields.pro_custom_attributes.category }}

Nothing shows up.

I try

{{ product.metafields.pro_custom_attributes.category.value }}

I make sure my products have a value for category (they do)
I make sure my pro_custom_attributes.category is set to read (it is)

What am I missing or doing wrong? Very frustrated.

Can only check with a collaborator access to your store as you seem to do it pretty much correct.

Best

Shadab

Hi @JamesPyle ,

Please change code:

{{ product.metafields.pro_custom_attributes.category }}

=>

{{ card_product.metafields.pro_custom_attributes.category }}

I tried that. I think the issue might be our Dawn is OLD. V2.4 while current version is 15.x

There’s not even a card-product in this version - it’s called product-card.

Hi @JamesPyle ,

Please send me the code of product-card.liquid file, I will check it for you

{% comment %}
    Renders a product card

    Accepts:
    - product_card_product: {Object} Product Liquid object (optional)
    - media_size: {String} Size of the product image card. Values are "square" and "portrait". Default is "square" (optional)
    - show_secondary_image: {Boolean} Show the secondary image on hover. Default: false (optional)
    - add_image_padding: {Boolean} Enables padding on the image to space out the grid
    - show_vendor: {Boolean} Show the product vendor. Default: false
    - show_image_outline: {Boolean} Show card outline. Default: true (optional)
    - show_rating: {Boolean} Show the product rating. Default: false

    Usage:
    {% render 'product-card', show_vendor: section.settings.show_vendor %}
{% endcomment %}

{{ 'component-rating.css' | asset_url | stylesheet_tag }}

  

    

            {%- if product_card_product.featured_media -%}
      ### 	  	          
      	  
            {{ product_card_product.title }}                               
          
                     
                
        {{ product.metafields.pro_custom_attributes.category.value }}       
        {{ product.metafields.pro_custom_attributes.category }}       
              
                              
      {%- endif -%}      
      {%- if show_vendor -%}
        {{ 'accessibility.vendor' | t }}
      
#### {{ product_card_product.vendor }}

      {%- endif -%}
          
         {% comment %} TODO: metafield {% endcomment %}
      {{ block.settings.description | escape }}
      {%- if show_rating and product_card_product.metafields.reviews.rating.value != blank -%}
        {% liquid
          assign rating_decimal = 0 
          assign decimal = product_card_product.metafields.reviews.rating.value.rating | modulo: 1 
          if decimal >= 0.3 and decimal <= 0.7
            assign rating_decimal = 0.5
          elsif decimal > 0.7
            assign rating_decimal = 1
          endif 
        %}
        

          
        

        

          {{ product_card_product.metafields.reviews.rating.value }} / {{ product_card_product.metafields.reviews.rating.value.scale_max }}
        

        

          ({{ product_card_product.metafields.reviews.rating_count }})
          {{ product_card_product.metafields.reviews.rating_count }} {{ "accessibility.total_reviews" | t }}
        

      {%- endif -%}
      
      {% comment } {% render 'price', product: product_card_product, price_class: '' %} {% endcomment %}
    

  

  
    

      {%- if product_card_product.featured_media -%}
        {%- liquid
          assign featured_media_aspect_ratio = product_card_product.featured_media.aspect_ratio

          if product_card_product.featured_media.aspect_ratio == nil
            assign featured_media_aspect_ratio = 1
          endif
        -%}

        

      {%- else -%}
        
          ## 
            
              {{ product_card_product.title }} 
            
          
           
        

      {%- endif -%}

      {% comment %}
      
        {%- if product_card_product.available == false -%}
          {{ 'products.product.sold_out' | t }}
        {%- elsif product_card_product.compare_at_price > product_card_product.price and product_card_product.available -%}
          {{ 'products.product.on_sale' | t }}
        {%- endif -%}
      

      {% endcomment %}
    

  

Thanks for looking. You can see where I was testing where these two lines are:
{{ product.metafields.pro_custom_attributes.category.value }}
{{ product.metafields.pro_custom_attributes.category }}

If I type something there like “test” it shows but the metafields do not show. There is a value for them for all products and there is a valid metafield. They show if I add them on the PDP page as custom liquid.

Hi @JamesPyle ,

You can try the following code:

{{ product_card_product.metafields.pro_custom_attributes.category.value }}

You are a genius, that worked! Thank you :slightly_smiling_face:

Hi @JamesPyle ,

You’re welcome and happy to help you :blush: