How to display metafields on product page

I have created a number of product metafields via Settings > Metafields:

How do I go about displaying the value of one of these metafields on the product page itself? I’ve tried doing a Google search and only get results related to custom metafields made using an app.

Any help would be greatly appreciated!

1 Like

@moolahdigital

sorry for this issue your can do without app shopify new feature

https://shopify.dev/api/liquid/objects/metafield

1 Like

Hello @moolahdigital ,

Use

{{ product.metafields.my_fields.product_benefit_3_image_ }}

{{ product.metafields.my_fields.product_benefit_3_text_ }}

{{ product.metafields.my_fields.product_benefit_2_image_ }}

{{ product.metafields.my_fields.product_benefit_2 }}

{{ product.metafields.my_fields.product_benefit_1_image_ }}

{{ product.metafields.my_fields.product_benefit_3_text_ }}
2 Likes

You can follow these steps:

Thank you @Guleria - this worked perfectly!

Hi @Guleria , Can you please let me know how this is work for product reference metafields

eg:

{{ item.product.metafields.product.cross_sell_product }}

Do you know how I can get the above product title , image and the handle.

Thank you!

Hi! I’m trying to achieve the same goal but with text metafields.

but then when I try to use them in my product-template.liquid page (see the code below)


    

{{product.metafields.my_fields.01_product_highlights}}

I get this error message:

Liquid syntax error (sections/main-product.liquid line 291): Expected id but found number in “{{product.metafields.my_fields.01_product_highlights}}”

Does anyone know how to solve this?

Thanks!

1 Like

@emanuelepasin

can you please just remove number of name for example 01 use different text

1 Like

It worked!!! Super thanks

1 Like

@emanuelepasin

it’s my pleasure to help us

1 Like

Hello,
I need you help about displaying metafields under a product

I have added the following code :

{%- if product.metafields.my_fields.besoin != blank -%}
{{ product.metafields.my_fields.besoin }}

{%- endif -%}

But it shows me the metafield with brackets and "
Could you please help me to correct this code to show only the text metafield
Thanks in advance

@bo6 I was having this happen too. I found out it’s because unless your metafield is a simple type like integer or string, you need to output the “value” of the metafield.

eg my “width” metafield is of type dimension. If you export the product you’ll see it’s stored as {“value”:56,“unit”:“cm”}

So this line:

Width: {{ product.metafields.custom.width }}

will display as:

Width: {“value”:56,“unit”:“cm”}

To output the values in the metafield, you need to add .value to the end of the metafield

Width: {{ product.metafields.custom.width.value }}

Width: 56 cm

If I wanted to display just the number from my Width metafield:

Width: {{ product.metafields.custom.width.value.value }}

Width: 56.0

If I wanted to display just the unit from my Width metafield:

Width: {{ product.metafields.custom.width.value.unit }}

Width: cm

etc.

Hi @KetanKumar

I wonder if you can help me too please?
I have been searching everywhere and asking everyoe and I can not figure this out! Nothing anyone says works for me!

I am using craft theme and I have created my metafields.. I have a post here but still nothing works..

https://community.shopify.com/c/shopify-design/craft-theme-can-t-change-the-descriptions-for-each-product/m-p/1927922#M513739