Class: Spree::ShippingMethod
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Spree::ShippingMethod
- 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
- #adjustment_label ⇒ Object
- #build_tracking_url(tracking) ⇒ Object
-
#frontend? ⇒ Boolean
Some shipping methods are only meant to be set via backend.
- #include?(address) ⇒ Boolean
Methods included from Core::CalculatedAdjustments
Class Method Details
.calculators ⇒ Object
38 39 40 |
# File 'app/models/spree/shipping_method.rb', line 38 def self.calculators spree_calculators.send(model_name_without_spree_namespace).select{ |c| c < Spree::ShippingCalculator } end |
Instance Method Details
#adjustment_label ⇒ Object
22 23 24 |
# File 'app/models/spree/shipping_method.rb', line 22 def adjustment_label Spree.t(:shipping) end |
#build_tracking_url(tracking) ⇒ Object
33 34 35 36 |
# File 'app/models/spree/shipping_method.rb', line 33 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
43 44 45 |
# File 'app/models/spree/shipping_method.rb', line 43 def frontend? self.display_on != "back_end" end |
#include?(address) ⇒ Boolean
26 27 28 29 30 31 |
# File 'app/models/spree/shipping_method.rb', line 26 def include?(address) return false unless address zones.any? do |zone| zone.include?(address) end end |