Class: Spree::ShippingMethod

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

Constant Summary collapse

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

Used for #refresh_rates

1
DISPLAY_ON_BACK_END =
2

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

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

.calculatorsObject



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

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

Instance Method Details

#available_to_display?(display_filter) ⇒ Boolean

Returns:

  • (Boolean)


49
50
51
52
# File 'app/models/spree/shipping_method.rb', line 49

def available_to_display?(display_filter)
  (frontend? && display_filter == DISPLAY_ON_FRONT_END) ||
  (backend? && display_filter == DISPLAY_ON_BACK_END)
end

#build_tracking_url(tracking) ⇒ Object



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

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

#include?(address) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
31
32
33
# File 'app/models/spree/shipping_method.rb', line 28

def include?(address)
  return false unless address
  zones.includes(:zone_members).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