How can I hide empty metafields on my product page?

Cosya
New Member
5 0 0

Hi!

I would like to hide metafields when they are empty. Who could help me with this difficulty please?

 

metafield.jpg

 

My theme is with Refresh.

My website is www.maisoncosya.com

Exemple of product page : https://maisoncosya.com/collections/accessoires/products/new-casual-style-school-backpack-16

I've tried a lot of tutorials, but haven't been successful with any...

Thanks!

Replies 6 (6)

deepaksharma
Shopify Partner
448 63 97

Hey @Cosya 

 

let's assume you metafield name is  product.metafields.custom.size_chart as shown in the screenshot

deepaksharma_0-1711293346563.png

 

then use code like the below example 

{% if product.metafields.custom.size_chart !=blank %}
    {{ product.metafields.custom.size_chart }}
  {% endif %}

 

If you are unable to implement the same then I'm happy to do this for you, let me know. I can implement the code changes so that this will work well for you.

 

Hopefully, it will help you. If yes then Please don't forget to hit Like and Mark it as the solution!

Deepak Sharma || Shopify Developer || Helping eCommerce Stores
- Was my reply helpful? Accept it as solution
- Was your question answered? Mark it as an Accepted Solution.
-CHAT ON WHATSAPP | BUY ME A COFFEE | MAIL ME: ds2305187@gmail.com
Cosya
New Member
5 0 0

Where should I put the code?

Thanks!

Cosya
New Member
5 0 0

I really can't do it myself unfortunately. Nothing seems to work. I would be happy if you can do it.

deepaksharma
Shopify Partner
448 63 97

Yeah sure I will be happy to fix it for you. Tell me how do you like to be helped?

Deepak Sharma || Shopify Developer || Helping eCommerce Stores
- Was my reply helpful? Accept it as solution
- Was your question answered? Mark it as an Accepted Solution.
-CHAT ON WHATSAPP | BUY ME A COFFEE | MAIL ME: ds2305187@gmail.com
Cosya
New Member
5 0 0

I don't know. This is the first time I've asked. I just want it to work 😆

deepaksharma
Shopify Partner
448 63 97

If you are interested then mail me I will implement this feature to your store

Deepak Sharma || Shopify Developer || Helping eCommerce Stores
- Was my reply helpful? Accept it as solution
- Was your question answered? Mark it as an Accepted Solution.
-CHAT ON WHATSAPP | BUY ME A COFFEE | MAIL ME: ds2305187@gmail.com