Why isn't my IF statement with metafields in OS 2.0 working?

Hi all,

I’m developing a custom block in OS 2.0 and inside the product-template.liquid file I’m using the

{%- when 'optical_link' -%}

to show the block when it’s selected from the theme editor.

Till here everything seems working fine, the link is visible and it works.

Now I need this section to appear only if the link is not blank so I’ve added the if statement as following

{%- when 'optical_link' -%}
  {%if product.metafileds.my_fields.optical_link != blank %}
     
     {{block.settings.optical_link_text}}  
     Click Here 
  

{% endif %}

Unfortunately when I add the if statement nothing is showing up even if the metafield is not blank.

If I remove the if statement everything works fine.

Is there someone who could help me out?

Did you copy and paste that code into this post?
There’s a typo - you have metfileds not metafields.

t was a typo in the copy paste, but thanks :folded_hands:

Anyway I’ve solved by using the .value

product.metafields.my_fields.optical_link.value

Good day.

I have the same problem. I have checked everywhere and can’t find any solution.

Below is my coding

For some reason it is just not returning any value after I have put this in.

{% if product.metafields.myfields.building_manual_image != blank %}

Click on the below image to download the building instructions

{% endif %}