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

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

.calculatorsObject



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

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)


51
52
53
54
# File 'app/models/spree/shipping_method.rb', line 51

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



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

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
34
# 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



47
48
49
# File 'app/models/spree/shipping_method.rb', line 47

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