Module: Spree::StoreHelper

Includes:
LocaleHelper
Defined in:
app/helpers/spree/store_helper.rb

Instance Method Summary collapse

Instance Method Details

#should_render_store_chooser?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'app/helpers/spree/store_helper.rb', line 30

def should_render_store_chooser?
  Spree::Frontend::Config[:show_store_selector] && stores.size > 1
end

#store_country_iso(store = nil) ⇒ Object



5
6
7
8
9
# File 'app/helpers/spree/store_helper.rb', line 5

def store_country_iso(store = nil)
  store ||= current_store if defined?(current_store)

  store&.default_country&.iso&.downcase
end

#store_currency_symbol(store = nil) ⇒ Object



15
16
17
18
19
20
# File 'app/helpers/spree/store_helper.rb', line 15

def store_currency_symbol(store = nil)
  store ||= current_store  if defined?(current_store)
  return unless store&.default_currency

  ::Money::Currency.find(store.default_currency).symbol
end


34
35
36
37
38
39
# File 'app/helpers/spree/store_helper.rb', line 34

def store_link(store = nil, html_opts = {})
  store ||= current_store if defined?(current_store)
  return unless store

  link_to "#{store_locale_name(store)} (#{store_currency_symbol(store)})", store.formatted_url, **html_opts
end

#store_locale_name(store = nil) ⇒ Object



22
23
24
25
26
27
28
# File 'app/helpers/spree/store_helper.rb', line 22

def store_locale_name(store = nil)
  store ||= current_store if defined?(current_store)
  return unless store
  return store.name if store.default_locale.blank?

  locale_full_name(store.default_locale)
end

#storesObject



11
12
13
# File 'app/helpers/spree/store_helper.rb', line 11

def stores
  @stores ||= Spree::Store.includes(:default_country).order(:id)
end