Class: Spree::ZonedController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/spree/zoned_controller.rb

Instance Method Summary collapse

Instance Method Details

#availLangs(country) ⇒ Object



4
5
6
# File 'app/controllers/spree/zoned_controller.rb', line 4

def availLangs(country)
  Rails.configuration.availableLanguages[country] || [["English", :en]]
end

#setcountryObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/spree/zoned_controller.rb', line 8

def setcountry
  respond_to do |format|
    format.js do
      if params[:order] && params[:order][:bill_address_attributes] && params[:order][:bill_address_attributes][:country_id]
        i = params[:order][:bill_address_attributes][:country_id].to_i.abs
      else
        i = params[:id].to_i.abs
      end
      i = -i if (Rails.application.config.commonCountriesForSelect.map { |a| a[1] }).include? -i
      i = i.to_s
      session[:zoned] ||= {}
      c = session[:zoned][:current_country] = i
      c = c.to_i
      session[:zoned][:current_language] = (availLangs(c) && availLangs(c)[0][1]) || "en"
    end
  end
end

#setlanguageObject



26
27
28
29
30
31
32
33
# File 'app/controllers/spree/zoned_controller.rb', line 26

def setlanguage
  respond_to do |format|
    format.js do
      session[:zoned] ||= {}
      session[:zoned][:current_language] = params[:lgid]
    end
  end
end