What's your biggest current challenge? Have your say in Community Polls along the right column.

Show false value for boolean Metafield in product detail view

Show false value for boolean Metafield in product detail view

TimoH
Shopify Partner
2 0 0

Hi,

 

i have several products with boolean values, which i want to display below the products in a value list.
My theme allows me to input metafields to display. If the metafield value is empty it will either not show or i can select to show empty values with a custom text, f.e. " - ".

 

My issue is that this also applies to boolean false values, showing " - " instead of "No" or simply not showing the entire field, if i select to not show empty fields. ( this is my prefered setting, since there are a lot of fields)

How can i change settings/liquid code so boolean false values will be shown as "No"?

shopify bool.png

 

Thank you and best regards

TimoH

Replies 2 (2)

PageFly-Theodor
Shopify Partner
691 86 103

Hi @TimoH ,
This is Theodore from PageFly - Shopify Page Builder App.

 

To show "No" for boolean "false" and hide empty metafields in Shopify:

  1. Edit theme code (e.g., product.liquid).
  2. Find metafield output code (loops or filters).
  3. Add Liquid code to check the metafield key and value:
    • If key matches your boolean field and value is "true", show "Yes".
    • If key matches and value is "false", show "No".
    • If key matches and value is empty (optional): hide the field with ``.
  4. Save and test on a non-live version of your store.


Best regards,
Theodore | PageFly

Please let me know if it works by giving it a Like or marking it as a solution!


PageFly - #1 Page Builder for Shopify merchants.


All features are available from Free plan. Live Chat Support is available 24/7.

TimoH
Shopify Partner
2 0 0

Hi Theodore,

 

thank you for your reply - is there a solution for addressing the field type? i am talking about 200+ metafields here.

 

Also, i just noticed that i can only create a max of 25 filters, id like to create way more tho. Is there a way to work around that max?

 

Best regards

TimoH