How can I add .01 to Compare at Price to prevent sale badge display?

pvgregory
Tourist
8 0 1

I keep running into errors when I try and add .01 to price so that the sale badge does not show up if the prices are $0.01 difference:

 

assign on_sale = false
if product.compare_at_price > product.price
assign on_sale = true
endif

 

Can I not just add plus: 0.01 to product.compare_at_price? Can someone please help with the language?

Reply 1 (1)

mavsalqueza
Shopify Partner
16 0 5
{%- liquid 

  assign on_sale = false
  
  if product.compare_at_price != null
    assign difference = product.price | minus: product.compare_at_price | round : 2
    
    if difference > 0.01
      assign on_sale = true
    endif
  endif
  
-%}