app/models/spree/variant_decorator.rb
# Returns true if the product is discounted by an amount that rounds to at least 1%
Returns true if the product is discounted by an amount that rounds to at least 1%
Returns true if the product is discounted by an amount that rounds to at least 1%
def discounted?
    begin
      price = self.price.respond_to?(:to_f) ? self.price.to_f : self.price.amount.to_f
      msrp = self.msrp.try(:to_f)
      msrp && self.price && ((1 - price / msrp) * 100).round > 0
    rescue
      false
    end
  end
def discounted? begin price = self . price . respond_to? ( :to_f ) ? self . price . to_f : self . price . amount . to_f msrp = self . msrp . try ( :to_f ) msrp && self . price && ( ( 1 - price / msrp ) * 100 ) . round > 0 rescue false end end
Returns true if the product is discounted by an amount that rounds to at least 1%
Returns true if the product is discounted by an amount that rounds to at least 1%