If Metafield is empty

Display content if a Metafield is not blank or empty.

Create your metafield. In the code below replace “examplefieldname” with the name of your metafield.

Create a custom liquid content section if your theme supports it in the customiser or directly copy and paste into the required template file.

{%- assign examplefieldname = product.metafields.my_fields.examplefieldname | metafield_tag -%}
{% if examplefieldname != blank %}

  <!-- add html here if required-->
  
<!-- Start output of the metafield content-->
   {{ product.metafields.my_fields.examplefieldname | metafield_tag }}
<!-- End output of the metafield content-->

{% endif %}

Leave a Reply

Your email address will not be published. Required fields are marked *

Get In Touch

Have a question? or perhaps spotted a problem?
Maybe you have something you would like to add. Drop us a line anytime!