Sha256: 73a89c44febd1c26d5090163b5a946d9ac529b75e00c52901b71761a88a8f4ea
Contents?: true
Size: 754 Bytes
Versions: 10
Compression:
Stored size: 754 Bytes
Contents
class Calculator::FlexiRate < Calculator preference :first_item, :decimal, :default => 0 preference :additional_item, :decimal, :default => 0 preference :max_items, :decimal, :default => 0 def self.description I18n.t("flexible_rate") end def self.available?(object) true end def self.register super Coupon.register_calculator(self) ShippingMethod.register_calculator(self) ShippingRate.register_calculator(self) end def compute(object) sum = 0 max = self.preferred_max_items object.length.times do |i| if (i % max == 0) && (max > 0) sum += self.preferred_first_item else sum += self.preferred_additional_item end end return(sum) end end
Version data entries
10 entries across 10 versions & 2 rubygems