Sha256: 8ed26d9dcfbf4256b2f061ab6a52c39b68d557d93d079b45fc2db519018a3c07
Contents?: true
Size: 760 Bytes
Versions: 1
Compression:
Stored size: 760 Bytes
Contents
require_dependency 'spree/calculator' module Spree class Calculator::FlexiRate < Calculator preference :first_item, :decimal, default: 0.0 preference :additional_item, :decimal, default: 0.0 preference :max_items, :integer, default: 0 preference :currency, :string, default: ->{ Spree::Config[:currency] } def self.available?(_object) true end def compute(object) sum = 0 max = preferred_max_items.to_i items_count = object.quantity items_count.times do |i| if i == 0 sum += preferred_first_item.to_f elsif ((max > 0) && (i <= (max - 1))) || (max == 0) sum += preferred_additional_item.to_f end end sum end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
solidus_core-2.1.0.beta1 | app/models/spree/calculator/flexi_rate.rb |