Compare at Price

pvgregory
Tourist
7 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
13 0 1
{%- 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
  
-%}