Class: Spree::Calculator::FlatRate

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Spree::Calculator

#available?, calculators, #description, #to_s

Methods inherited from Base

belongs_to_required_by_default, page, spree_base_scopes

Methods included from Preferences::Preferable

#clear_preferences, #default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference

Class Method Details

.descriptionObject


8
9
10
# File 'app/models/spree/calculator/flat_rate.rb', line 8

def self.description
  Spree.t(:flat_rate_per_order)
end

Instance Method Details

#compute(object = nil) ⇒ Object


12
13
14
15
16
17
18
# File 'app/models/spree/calculator/flat_rate.rb', line 12

def compute(object = nil)
  if object && preferred_currency.casecmp(object.currency.upcase).zero?
    preferred_amount
  else
    0
  end
end