Class: Spree::ShippingMethod

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Core::CalculatedAdjustments
Defined in:
app/models/spree/shipping_method.rb

Constant Summary collapse

DISPLAY =
[:both, :front_end, :back_end]

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Core::CalculatedAdjustments

included

Class Method Details

.calculatorsObject



36
37
38
# File 'app/models/spree/shipping_method.rb', line 36

def self.calculators
  spree_calculators.send(model_name_without_spree_namespace).select{ |c| c < Spree::ShippingCalculator }
end

Instance Method Details

#build_tracking_url(tracking) ⇒ Object



31
32
33
34
# File 'app/models/spree/shipping_method.rb', line 31

def build_tracking_url(tracking)
  return if tracking.blank? || tracking_url.blank?
  tracking_url.gsub(/:tracking/, ERB::Util.url_encode(tracking)) # :url_encode exists in 1.8.7 through 2.1.0
end

#frontend?Boolean

Some shipping methods are only meant to be set via backend

Returns:

  • (Boolean)


41
42
43
# File 'app/models/spree/shipping_method.rb', line 41

def frontend?
  self.display_on != "back_end"
end

#include?(address) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
27
28
29
# File 'app/models/spree/shipping_method.rb', line 24

def include?(address)
  return false unless address
  zones.any? do |zone|
    zone.include?(address)
  end
end

#tax_categoryObject



45
46
47
# File 'app/models/spree/shipping_method.rb', line 45

def tax_category
  Spree::TaxCategory.unscoped { super }
end