Re: Hide metafields when they are blank

Solved

How can I hide blank metafields on my product page?

OH2
Shopify Partner
11 0 2

Hi community, I created my Metafields on my product page. I want to hide the metafileds that don't have information when the user is seeing the page. See attached screenshot.

 

Screen Shot 2022-06-16 at 5.23.03 PM.pngIm using Dawn Them 2.0 if it helps. I haven't added any extra code to it. 

 

I really appreciate any help!!

Accepted Solutions (2)
LitExtension
Shopify Partner
4860 1002 1159

This is an accepted solution.

Hi @OH2,

Please find 'richtext' and change 'liquid'. Refer:

Screenshot.png

Then you can add conditions to show Metafields. Example for Binding:

{%- if product.metafields.my_fields.binding != blank -%}
Binding: {{ product.metafields.my_fields.binding }}
{%- endif -%}

Hope it helps!

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify

View solution in original post

LitExtension
Shopify Partner
4860 1002 1159

This is an accepted solution.

Hi @OH2,

You just go to customize and add the code directly at Description. 

Screenshot.png

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify

View solution in original post

Replies 21 (21)

LitExtension
Shopify Partner
4860 1002 1159

Hi @OH2,

You can add conditions to it, for example:

{%- if product.metafields.instructions.wash != blank -%}
<!-- show metafields -->
{%- endif -%}

Hope it helps!

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
OH2
Shopify Partner
11 0 2

Hi @LitExtension, Thanks for your answer. I'm new here with Shopify. Can you point me out where I can add the conditions? I'm thinking I have to add it on the product.json  

LitExtension
Shopify Partner
4860 1002 1159

Hi @OH2,

Can you send me a screenshot where you have added the option to show Metafields? i will help you check it.

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
OH2
Shopify Partner
11 0 2

 I added here @LitExtension 

Screen Shot 2022-06-17 at 10.51.53 AM.png

LitExtension
Shopify Partner
4860 1002 1159

Hi @OH2,

It's not at Metafields, where you added to show it at the frontend.

is it in Customize or in the edit theme?

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
OH2
Shopify Partner
11 0 2

@LitExtension I added it in the theme editor. 

LitExtension
Shopify Partner
4860 1002 1159

Hi @OH2,

Can you send me a screenshot editor? I will check it.

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
OH2
Shopify Partner
11 0 2

@LitExtension  here is the Screenshot

Screen Shot 2022-06-20 at 11.21.27 AM.png

LitExtension
Shopify Partner
4860 1002 1159

Hi @OH2,

I checked and you can't add conditions here. If you want, you can just create a new section, and declare the metafields directly in the code, it will help you to add conditions to it.

Do you want to create a new section and manually declare metafields?

Please send me the code of multicolumn.liquid file, I will guide you step by step to change it 

 

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
OH2
Shopify Partner
11 0 2

@LitExtension here is the code for the multicolumn section. Thanks again for helping me!!

LitExtension
Shopify Partner
4860 1002 1159

Hi @OH2,

It is not JSON, please send me the code file, sections > multicolumn.liquid file, I will check it.

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
OH2
Shopify Partner
11 0 2

HI @LitExtension, I upload the wrong file, here is the full code. 
Thanks

LitExtension
Shopify Partner
4860 1002 1159

This is an accepted solution.

Hi @OH2,

Please find 'richtext' and change 'liquid'. Refer:

Screenshot.png

Then you can add conditions to show Metafields. Example for Binding:

{%- if product.metafields.my_fields.binding != blank -%}
Binding: {{ product.metafields.my_fields.binding }}
{%- endif -%}

Hope it helps!

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
OH2
Shopify Partner
11 0 2

Hey, @LitExtension I made the changes you told me to and added the code into  product. json and is working. Let me know if this is the place where I had to add the code. Thanks again!!!

Screen Shot 2022-06-28 at 2.14.56 PM.png

LitExtension
Shopify Partner
4860 1002 1159

This is an accepted solution.

Hi @OH2,

You just go to customize and add the code directly at Description. 

Screenshot.png

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
OH2
Shopify Partner
11 0 2

Thank you @LitExtension. for all your help!! 

Tupperton
Shopify Partner
22 0 5

I've added the code, but did i do something wrong? It's just showing the entire code instead:

 

Tupperton_0-1662023368054.png

I've added the liquid code to multicolumn as instructed:

Tupperton_1-1662023528845.png

 

 

https://housedoctor.com
LitExtension
Shopify Partner
4860 1002 1159

Hi @Tupperton,

You can create a question on the community and send me the link. I will check it.
Because this will help build a better community.
Thank you.

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
Tupperton
Shopify Partner
22 0 5

I don't quite understand your reasoning, as it is directly related to the question above.

 

Nontheless i've created another question as requested 🙂 

https://community.shopify.com/c/technical-q-a/hide-metafields-when-blank-through-description/m-p/172...

 

https://housedoctor.com
fixpc82
Visitor
1 0 0

Where should this code be pasted?

 

{%- if product.metafields.my_fields.binding != blank -%}
Binding: {{ product.metafields.my_fields.binding }}
{%- endif -%}

MRamzan
Shopify Partner
298 3 34

I just followed this video guide steps to hide the metafileds from my product page which were blank:

 

Video: https://youtu.be/_9rtNdM6n1A

Hire Me:

WhatsApp: +91-9145985880
Email: [email protected]
Skype: mohdramzaan112