Why isn't the 'if blank' condition functioning correctly?

Why isn't the 'if blank' condition functioning correctly?

Hemsyd
Excursionist
22 0 3

Hello
Wondering why this "if blank" doesn't work?

 

{%- if product.compare_at_price_max !=blank %}
<span class="labelNew">{{ product.compare_at_price_max | minus: product.price | times:100 | divided_by:product.compare_at_price_max  }}</span>
  {%- endif -%}
www.hemsyd.se
Replies 8 (8)

made4Uo
Shopify Partner
3873 718 1221

Hi @Hemsyd 

 

You need to have a space between the "=" and the word blank

 

{%- if product.compare_at_price_max != blank %}
<span class="labelNew">{{ product.compare_at_price_max | minus: product.price | times:100 | divided_by:product.compare_at_price_max  }}</span>
  {%- endif -%}

 

If this fixed your issue Likes and Accept as Solution is highly appreciated. Coffee tips fuels my dedication.
Get EXPERIENCED Shopify developers at affordable rates—visit Made4Uo.com for quick quote!
Do not lost your Shopify store! Get FREE trial with ✔️ Rewind Backup: Automatic, reliable, stress-free
Hemsyd
Excursionist
22 0 3

Thanks for your help, but the same thing. I want it to be hidden when I don't have a discount. but now it shows (0)Skärmbild 2022-09-16 213607.png

www.hemsyd.se
made4Uo
Shopify Partner
3873 718 1221

Oh. Try this code instead

 

{%- if product.compare_at_price_max != "0" %}
<span class="labelNew">{{ product.compare_at_price_max | minus: product.price | times:100 | divided_by:product.compare_at_price_max  }}</span>
{%- endif -%}

 

If this fixed your issue Likes and Accept as Solution is highly appreciated. Coffee tips fuels my dedication.
Get EXPERIENCED Shopify developers at affordable rates—visit Made4Uo.com for quick quote!
Do not lost your Shopify store! Get FREE trial with ✔️ Rewind Backup: Automatic, reliable, stress-free
Hemsyd
Excursionist
22 0 3

Thanks
but the same zero remains!

www.hemsyd.se
Hemsyd
Excursionist
22 0 3

Someone who can be of help

www.hemsyd.se
made4Uo
Shopify Partner
3873 718 1221

Hi, 

 

Try the code below instead

{%- if product.compare_at_price_max != 0 %}
<span class="labelNew">{{ product.compare_at_price_max | minus: product.price | times:100 | divided_by:product.compare_at_price_max  }}</span>
{%- endif -%}

 

If this fixed your issue Likes and Accept as Solution is highly appreciated. Coffee tips fuels my dedication.
Get EXPERIENCED Shopify developers at affordable rates—visit Made4Uo.com for quick quote!
Do not lost your Shopify store! Get FREE trial with ✔️ Rewind Backup: Automatic, reliable, stress-free
Hemsyd
Excursionist
22 0 3

Hello
It's the same, I don't want it to show zero. I want it to be visible only when it is damaged

www.hemsyd.se
made4Uo
Shopify Partner
3873 718 1221

You have to find a way to differentiate the variables

If this fixed your issue Likes and Accept as Solution is highly appreciated. Coffee tips fuels my dedication.
Get EXPERIENCED Shopify developers at affordable rates—visit Made4Uo.com for quick quote!
Do not lost your Shopify store! Get FREE trial with ✔️ Rewind Backup: Automatic, reliable, stress-free