Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
I would like to add a liquid code to my shop that would display more detailed product information. I already have this information completed using metafields. I'll add that it's the content type - Single line of text (List).
And it displays not the way I would like it to, because the "" and [] character are added. How can I get rid of them? Below is my code.
<div class="productView-bottom"> <div class="container"> <h3 class="title"><span class="text">Product Detail:</span></h3> {% if product.metafields.my_fields.package_quantity %} <p>Package Quantity: {{product.metafields.my_fields.package_quantity}}</p> {% endif %} {% if product.metafields.my_fields.certification_and_diet %} <p>Certification and Diet: {{ product.metafields.my_fields.certification_and_diet }}</p> {% endif %} </div> </div>
Link below to an example of a product that has the data listed just before the section with related products.
https://medpak.shop/products/now-foods-zinc-50-mg-100-tablets
Solved! Go to the solution
This is an accepted solution.
try add .value to metafield, like:
<p>Package Quantity: {{product.metafields.my_fields.package_quantity.value}}</p>
I guess we didn't quite understand each other, because I just want to get rid of those elements marked on the screenshot.
It looks like this is not the solution, as this is then what the code looks like as I remove one {} at a time.
This is an accepted solution.
try add .value to metafield, like:
<p>Package Quantity: {{product.metafields.my_fields.package_quantity.value}}</p>
Yes, that helped and it displays correctly.
However, now I have another problem to solve. How can I translate all this now? First of all with the values that are in the metafields?
I think there no default way for metafield translation, so i think you need create something like this:
metafield_title_en: 'Text',
metafield_title_it: 'Text italy'
{% liquid
assign lang_code = 'en'
if ...statement to define italic code...
assign lang_code = 'it'
endif
assign metafield_title = 'metafield_title_' | append: lang_code
%}
<p>Title: {{product.metafields.my_fields[metafield_title].value}}</p>
Hello @kazunari
It seems like you values are stored in arrays(list), which you can see based on the brackets.
To show only the values you can use an array filter with custom separator as described here:
https://shopify.dev/api/liquid/filters/join#join-custom-separator
so in your case you would use e.g.:
{{product.metafields.my_fields.package_quantity | join: ', '}}
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