Sha256: 6c2dfa4bab067f09b924b66f04aadea942e8409afbde6fbb0bed8ca858dcff65

Contents?: true

Size: 976 Bytes

Versions: 26

Compression:

Stored size: 976 Bytes

Contents

module Spree
  module CurrencyHelper
    def currency_options(selected_value = nil)
      selected_value ||= Spree::Store.default.default_currency
      currencies = ::Money::Currency.table.map do |_code, details|
        iso = details[:iso_code]
        [iso, "#{details[:name]} (#{iso})"]
      end
      options_from_collection_for_select(currencies, :first, :last, selected_value)
    end

    def supported_currency_options
      return if current_store.nil?

      current_store.supported_currencies_list.map(&:iso_code).map { |currency| currency_presentation(currency) }
    end

    def should_render_currency_dropdown?
      return false if current_store.nil?

      current_store.supported_currencies_list.size > 1
    end

    def currency_symbol(currency)
      ::Money::Currency.find(currency).symbol
    end

    def currency_presentation(currency)
      label = [currency_symbol(currency), currency].compact.join(' ')

      [label, currency]
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
spree_core-4.10.1 app/helpers/spree/currency_helper.rb
spree_core-4.10.0 app/helpers/spree/currency_helper.rb
spree_core-4.9.0 app/helpers/spree/currency_helper.rb
spree_core-4.8.3 app/helpers/spree/currency_helper.rb
spree_core-4.8.2 app/helpers/spree/currency_helper.rb
spree_core-4.7.3 app/helpers/spree/currency_helper.rb
spree_core-4.6.6 app/helpers/spree/currency_helper.rb
spree_core-4.5.5 app/helpers/spree/currency_helper.rb
spree_core-4.4.1 app/helpers/spree/currency_helper.rb
spree_core-4.5.4 app/helpers/spree/currency_helper.rb
spree_core-4.6.5 app/helpers/spree/currency_helper.rb
spree_core-4.7.2 app/helpers/spree/currency_helper.rb
spree_core-4.7.1 app/helpers/spree/currency_helper.rb
spree_core-4.6.4 app/helpers/spree/currency_helper.rb
spree_core-4.7.0 app/helpers/spree/currency_helper.rb
spree_core-4.6.3 app/helpers/spree/currency_helper.rb
spree_core-4.6.2 app/helpers/spree/currency_helper.rb
spree_core-4.6.1 app/helpers/spree/currency_helper.rb
spree_core-4.6.0 app/helpers/spree/currency_helper.rb
spree_core-4.5.3 app/helpers/spree/currency_helper.rb