Class: Spree::Calculator::TieredFlatRate

Inherits:
Spree::Calculator show all
Defined in:
core/app/models/spree/calculator/tiered_flat_rate.rb

Instance Method Summary collapse

Methods inherited from Spree::Calculator

#available?, calculators, description, #description, #to_s

Methods inherited from Base

display_includes, #initialize_preference_defaults, page, preference

Instance Method Details

#compute(object) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'core/app/models/spree/calculator/tiered_flat_rate.rb', line 22

def compute(object)
  _base, amount = preferred_tiers.sort.reverse.detect do |b, _|
    object.amount >= b
  end

  if preferred_currency.casecmp(object.currency).zero?
    amount || preferred_base_amount
  else
    0
  end
end