Class: Spree::Store

Inherits:
Base
  • Object
show all
Defined in:
app/models/spree/store.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

display_includes, #initialize_preference_defaults, page, preference

Methods included from Preferences::Preferable

#default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference

Class Method Details

.current(store_key = nil) ⇒ Object



17
18
19
20
21
# File 'app/models/spree/store.rb', line 17

def self.current(store_key = nil)
  Spree::Deprecation.warn "Spree::Store.current needs a code or URL as an argument. If you want the default store use Spree::Store.default", caller if !store_key
  current_store = Store.find_by(code: store_key) || Store.by_url(store_key).first if store_key
  current_store || Store.default
end

.defaultObject



23
24
25
# File 'app/models/spree/store.rb', line 23

def self.default
  where(default: true).first || new
end

Instance Method Details

#default_cart_tax_locationObject



27
28
29
30
# File 'app/models/spree/store.rb', line 27

def default_cart_tax_location
  @default_cart_tax_location ||=
    Spree::Tax::TaxLocation.new(country: Spree::Country.find_by(iso: cart_tax_country_iso))
end