how to hide a collapsible row metafield when its blank

https://www.awakeningra.com/products/khnum?_pos=1&_psq=kh&_ss=e&_v=1.0

I want to hide the collapsible row field “material powers” when its black for a product how could I do this ?

@tarekanani Does every product on your site not have this field?

some of them has it and some doesn’t contain any info for this one

@tarekanani Can you show me a product that has that part?

Previous Question Asked and Solved

https://community.shopify.com/c/technical-q-a/can-t-get-custom-meta-fields-to-disappear-if-blank/m-p/2639446#M168345

this product has no info for this metafield

does this work with any theme ? and I have a multi-word metafield “material powers” How could I contain this to the code ?

Instructions

  1. Go to ‘Online Store’ → Theme

  2. In your Active Theme click on the 3 dots (…) → Edit Code

  3. In the Sections folder locate the file ‘main-product.liquid’ or similar.

  4. Find {%- when ‘collapsible_tab’ -%}

  5. Below the {%- when ‘collapsible_tab’ -%} you will see something like this

{%- when 'collapsible_tab' -%}
  
    
  

  1. Surround everything in an if statement like this:
{%- when 'collapsible_tab' -%}
  {% if block.settings.content != blank or block.settings.page.content != blank %}
  
    
  

{% endif %}

This should work

thanks this worked !

@WalkYourStyle I’ve tried this and I’m getting this errors, ideas? I added the following only, did I miss something or place in the wrong place?

{% if block.settings.content != blank or block.settings.page.content != blank %}

You forgot to close the if statement like this : {% endif %} at the end

1 Like

Thank you!