Class: SolidusPromotions::Calculators::TieredFlatRate

Inherits:
Spree::Calculator
  • Object
show all
Includes:
PromotionCalculator
Defined in:
app/models/solidus_promotions/calculators/tiered_flat_rate.rb

Instance Method Summary collapse

Methods included from PromotionCalculator

#description

Instance Method Details

#compute_item(object) ⇒ Object Also known as: compute_shipment, compute_line_item



25
26
27
28
29
30
31
32
33
34
35
# File 'app/models/solidus_promotions/calculators/tiered_flat_rate.rb', line 25

def compute_item(object)
  _base, amount = preferred_tiers.sort.reverse.detect do |value, _|
    object.discountable_amount >= value
  end

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