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



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

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

Instance Method Details

#adjustment_labelObject



21
22
23
# File 'app/models/spree/shipping_method.rb', line 21

def adjustment_label
  Spree.t(:shipping)
end

#build_tracking_url(tracking) ⇒ Object



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

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)


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

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

#include?(address) ⇒ Boolean

Returns:

  • (Boolean)


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

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