Class: Spree::CurrencyController

Inherits:
StoreController show all
Defined in:
app/controllers/spree/currency_controller.rb

Instance Method Summary collapse

Methods inherited from StoreController

#account_link, #api_tokens, #cart_link, #ensure_cart

Instance Method Details

#setObject



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'app/controllers/spree/currency_controller.rb', line 3

def set
  new_currency = params[:switch_to_currency]&.upcase

  if new_currency.present? && supported_currency?(new_currency)
    current_order&.update(currency: new_currency)
    session[:currency] = new_currency
  end

  respond_to do |format|
    format.html { redirect_back fallback_location: spree.root_path(currency: new_currency) }
    format.json { head :ok }
  end
end