Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Include currency symbol in currency dropdown
Damian Legawiec91fa208380e2
diff --git a/core/app/helpers/spree/currency_helper.rb b/core/app/helpers/spree/currency_helper.rbindex f421c68124..cc55ac1aa5 100644--- a/core/app/helpers/spree/currency_helper.rb+++ b/core/app/helpers/spree/currency_helper.rb@@ -12,7 +12,7 @@ module Spreedef supported_currency_optionsreturn if current_store.nil?- current_store.supported_currencies_list.map(&:iso_code)+ current_store.supported_currencies_list.map(&:iso_code).map { |currency| currency_presentation(currency) }enddef should_render_currency_dropdown?@@ -20,5 +20,15 @@ module Spreecurrent_store.supported_currencies_list.size > 1end++ def currency_symbol(currency)+ ::Money::Currency.find(currency).symbol+ end++ def currency_presentation(currency)+ label = [currency_symbol(currency), currency].compact.join(' ')++ [label, currency]+ endendenddiff --git a/core/spec/helpers/currency_helper_spec.rb b/core/spec/helpers/currency_helper_spec.rbindex 9fae1f65c6..559391d16b 100644--- a/core/spec/helpers/currency_helper_spec.rb+++ b/core/spec/helpers/currency_helper_spec.rb@@ -4,7 +4,7 @@ describe Spree::CurrencyHelper, type: :helper dolet(:current_store) { create(:store, default_currency: 'EUR', supported_currencies: 'EUR,PLN,GBP') }describe '#supported_currency_options' do- it { expect(supported_currency_options).to contain_exactly('EUR', 'GBP', 'PLN') }+ it { expect(supported_currency_options).to contain_exactly(['zł PLN', 'PLN'], ['£ GBP', 'GBP'], ['€ EUR', 'EUR']) }enddescribe '#should_render_currency_dropdown?' do@@ -18,4 +18,12 @@ describe Spree::CurrencyHelper, type: :helper doit { expect(should_render_currency_dropdown?).to be_falsey }endend++ describe '#currency_symbol' do+ it { expect(currency_symbol('EUR')).to eq('€') }+ end++ describe '#currency_presentation' do+ it { expect(currency_presentation('EUR')).to eq(['€ EUR', 'EUR']) }+ endenddiff --git a/frontend/spec/features/product_prices_spec.rb b/frontend/spec/features/product_prices_spec.rbindex 5ce3ace7cc..814861b4c3 100644--- a/frontend/spec/features/product_prices_spec.rb+++ b/frontend/spec/features/product_prices_spec.rb@@ -24,7 +24,7 @@ describe 'Product with prices in multiple currencies', type: :feature, js: trueexpect(page).to have_text '£23.00'expect(page).to have_link product.name, href: "/products/#{product.slug}?currency=GBP"open_i18n_menu- expect(page).to have_select('switch_to_currency', selected: 'GBP')+ expect(page).to have_select('switch_to_currency', selected: '£ GBP')close_i18n_menuswitch_to_currency('USD')expect(page).to have_text '$19.99'