Solved

Show only the metadata fields that are filled

trumansclub
Excursionist
13 0 3

Hello! So the thing is I like a lot the new Dawn theme, but I wonder how can I play with the metadata fields so I can only show the fields that contain information. So for example in some of my products I have a retractable tab with "Features", "Materials" and "Size", but in other product I might have info in "How to use it" for example. I just want the product to show this retractable tabs when they contain information in the product. I don't want for example to click on "Size" and nothing shows up.

Is it posible to do this?

 

trumansclub_0-1633803529678.png

 

Accepted Solution (1)

iambrianclark
Shopify Partner
21 3 13

This is an accepted solution.

I solved an issue just like this by adding an if statement in my template code.

{% when 'block' %} // eg. "Materials"
    // ...original code for the accordion

{% when 'block' %}
    {% if metafield.product.namespace.key %}
        // ...original code for the accordion
    {% endif %}

View solution in original post

Reply 1 (1)

iambrianclark
Shopify Partner
21 3 13

This is an accepted solution.

I solved an issue just like this by adding an if statement in my template code.

{% when 'block' %} // eg. "Materials"
    // ...original code for the accordion

{% when 'block' %}
    {% if metafield.product.namespace.key %}
        // ...original code for the accordion
    {% endif %}