Shopify themes, liquid, logos, and UX
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!
Solved! Go to the solution
This is an accepted solution.
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_ }}
sorry for this issue your can do without app shopify new feature
https://shopify.dev/api/liquid/objects/metafield
This is an accepted solution.
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_ }}
Hi @Developer-G , 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)
<div class="product-highlight">
<p>{{product.metafields.my_fields.01_product_highlights}}</p>
</div>
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!
can you please just remove number of name for example 01 use different text
It worked!!! Super thanks
it's my pleasure to help us
Hello,
I need you help about displaying metafields under a product
I have added the following code :
{%- if product.metafields.my_fields.besoin != blank -%}
<div class="besoin-produit">{{ product.metafields.my_fields.besoin }}</div>
{%- 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..
You can follow these steps:
- Step 1: Go to products and select value for each Metafields. Refer https://i.imgur.com/WqyoeMh.png
- Step 2: Create a json template, choose the template for the products you want to create with that json template. Refer https://shopify.dev/themes/architecture/templates#json-templates
Ex: https://github.com/Shopify/dawn/blob/main/templates/product.json
- Step 3: Go to Customize and start selecting Metafields for it.
Hope it clear to you.
Are you ready to take your business to the next level? Look no further than the latest ...
By SarahF_Shopify Apr 15, 2024We’re keeping the ball rolling to make sure you’re always ahead of the game. So buckle ...
By JasonH Apr 8, 2024Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024