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
SD-959 rename allow_currency_change to show_store_selector
KacperMekarskiae37c375ef65
diff --git a/backend/app/controllers/spree/admin/general_settings_controller.rb b/backend/app/controllers/spree/admin/general_settings_controller.rbindex 1e5ad4783c..7dee44ef16 100644--- a/backend/app/controllers/spree/admin/general_settings_controller.rb+++ b/backend/app/controllers/spree/admin/general_settings_controller.rb@@ -27,7 +27,7 @@ module Spreeenddef render(*args)- @preferences_currency |= [:allow_currency_change]+ @preferences_currency |= [:show_store_selector]superenddiff --git a/backend/app/views/spree/admin/general_settings/_form.html.erb b/backend/app/views/spree/admin/general_settings/_form.html.erbindex 3a82e8bb5f..47557c5d4a 100644--- a/backend/app/views/spree/admin/general_settings/_form.html.erb+++ b/backend/app/views/spree/admin/general_settings/_form.html.erb@@ -7,10 +7,10 @@<div class="form-group"><div class="checkbox"><label>- <%= check_box('', :allow_currency_change, { checked: Spree::Config.allow_currency_change }) %>- <%= Spree.t('allow_currency_change.short') %>+ <%= check_box('', :show_store_selector, { checked: Spree::Config.show_store_selector }) %>+ <%= Spree.t('show_store_selector.short') %></label>- <p class="help-block"><%= Spree.t('allow_currency_change.long') %></p>+ <p class="help-block"><%= Spree.t('show_store_selector.long') %></p></div></div></div>diff --git a/backend/spec/features/admin/general_settings/prices_settings_updating_spec.rb b/backend/spec/features/admin/general_settings/prices_settings_updating_spec.rbindex 64e9ca6b9e..93c8688e95 100644--- a/backend/spec/features/admin/general_settings/prices_settings_updating_spec.rb+++ b/backend/spec/features/admin/general_settings/prices_settings_updating_spec.rb@@ -7,7 +7,7 @@ describe 'Updating currencies settings', type: :feature, js: true dodescribe 'enabling currency settings' dobefore doreset_spree_preferences do |config|- config.allow_currency_change = false+ config.show_store_selector = falseendend@@ -15,35 +15,35 @@ describe 'Updating currencies settings', type: :feature, js: true dovisit spree.edit_admin_general_settings_path# Test initial state- expect(page).to have_unchecked_field('allow_currency_change')+ expect(page).to have_unchecked_field('show_store_selector')# Interact with the form- check('allow_currency_change')+ check('show_store_selector')click_button 'Update'# Test final stateexpect(page).to have_content 'General Settings has been successfully updated!'- expect(page).to have_checked_field('allow_currency_change')+ expect(page).to have_checked_field('show_store_selector')endenddescribe 'disabling currency settings' dobefore doreset_spree_preferences do |config|- config.allow_currency_change = true+ config.show_store_selector = trueendendit 'allows to disable currency settings' dovisit spree.edit_admin_general_settings_path- expect(page).to have_checked_field('allow_currency_change')+ expect(page).to have_checked_field('show_store_selector')- uncheck('allow_currency_change')+ uncheck('show_store_selector')click_button 'Update'expect(page).to have_content 'General Settings has been successfully updated!'- expect(page).to have_unchecked_field('allow_currency_change')+ expect(page).to have_unchecked_field('show_store_selector')endendenddiff --git a/core/app/models/spree/app_configuration.rb b/core/app/models/spree/app_configuration.rbindex 4000ec9002..d91c4feea8 100644--- a/core/app/models/spree/app_configuration.rb+++ b/core/app/models/spree/app_configuration.rb@@ -69,7 +69,7 @@ module Spreepreference :credit_to_new_allocation, :boolean, default: false# Multi currency configurations- preference :allow_currency_change, :boolean, default: false+ preference :show_store_selector, :boolean, default: false# searcher_class allows spree extension writers to provide their own Search classdef searcher_classdiff --git a/core/app/models/spree/line_item.rb b/core/app/models/spree/line_item.rbindex 8a2ee06777..13deb0dc89 100644--- a/core/app/models/spree/line_item.rb+++ b/core/app/models/spree/line_item.rb@@ -57,7 +57,7 @@ module Spreeenddef update_price- if Spree::Config.allow_currency_change == true+ if Spree::Config.show_store_selector == truecurrency_price = Spree::Price.where(currency: order.currency,variant_id: variant_iddiff --git a/core/config/locales/en.yml b/core/config/locales/en.ymlindex c91aec85b9..06d38f928a 100644--- a/core/config/locales/en.yml+++ b/core/config/locales/en.yml@@ -574,9 +574,6 @@ en:agree_to_privacy_policy: Agree to Privacy Policyagree_to_terms_of_service: Agree to Terms of Serviceall: All- allow_currency_change:- short: Allow Currency Change- long: Display the currency picker in the main nav bar and allow users to change their currency via it. In addition, multiple stores must be supported.all_adjustments_closed: All adjustments successfully closed!all_adjustments_opened: All adjustments successfully opened!all_departments: All departments@@ -1576,6 +1573,9 @@ en:show_only_considered_risky: Only show risky ordersshow_property: Show Propertyshow_rate_in_label: Show rate in label+ show_store_selector:+ short: Allow Currency Change+ long: Display the currency picker in the main nav bar and allow users to change their currency via it. In addition, multiple stores must be supported.sign_up: Sign Upsku: SKUskus: SKUsdiff --git a/core/spec/models/spree/line_item_spec.rb b/core/spec/models/spree/line_item_spec.rbindex b047bd3cd4..367f7f6d56 100644--- a/core/spec/models/spree/line_item_spec.rb+++ b/core/spec/models/spree/line_item_spec.rb@@ -187,7 +187,7 @@ describe Spree::LineItem, type: :model doexpect(price).to receive(:price_including_vat_for).and_return(12)reset_spree_preferences do |config|- config.allow_currency_change = true+ config.show_store_selector = trueendenddiff --git a/frontend/app/controllers/spree/currency_controller.rb b/frontend/app/controllers/spree/currency_controller.rbindex 79a4e9f8ff..ce274d82e7 100644--- a/frontend/app/controllers/spree/currency_controller.rb+++ b/frontend/app/controllers/spree/currency_controller.rb@@ -4,7 +4,7 @@ module Spree@currency = supported_currencies.find { |currency| currency.iso_code == params[:currency] }# Make sure that we update the current order, so the currency change is reflected.current_order&.update_attributes!(currency: @currency.iso_code)- session[:currency] = params[:currency] if Spree::Config[:allow_currency_change]+ session[:currency] = params[:currency] if Spree::Config[:show_store_selector]respond_to do |format|format.json { render json: [email protected]? }format.html dodiff --git a/frontend/app/views/spree/shared/_change_store.html.erb b/frontend/app/views/spree/shared/_change_store.html.erbindex 2f12c1c3b4..d76d0245a8 100644--- a/frontend/app/views/spree/shared/_change_store.html.erb+++ b/frontend/app/views/spree/shared/_change_store.html.erb@@ -1,4 +1,4 @@-<% if Spree::Config.allow_currency_change && stores.size > 1 %>+<% if Spree::Config.show_store_selector && stores.size > 1 %><li class="change-store"><div class="dropdown navbar-right-dropdown"><button id="stores-button" type="button" data-toggle="dropdown" class="navbar-right-dropdown-toggle" aria-label="<%= Spree.t('nav_bar.change_country')%>">diff --git a/frontend/spec/features/main_nav_bar_spec.rb b/frontend/spec/features/main_nav_bar_spec.rbindex bad7065ab8..d1875c252a 100644--- a/frontend/spec/features/main_nav_bar_spec.rb+++ b/frontend/spec/features/main_nav_bar_spec.rb@@ -12,12 +12,12 @@ describe 'Main navigation bar', type: :feature doendend- context 'when allow_currency_change preference is set to true' do+ context 'when show_store_selector preference is set to true' dolet!(:stores) { create_list(:store, stores_number, default_country: create(:country)) }before doreset_spree_preferences do |config|- config.allow_currency_change = true+ config.show_store_selector = trueendvisit spree.root_path@@ -51,12 +51,12 @@ describe 'Main navigation bar', type: :feature doendend- context 'when allow_currency_change preference is set to false' do+ context 'when show_store_selector preference is set to false' dolet!(:stores) { create_list(:store, stores_number) }before doreset_spree_preferences do |config|- config.allow_currency_change = false+ config.show_store_selector = falseendvisit spree.root_pathdiff --git a/frontend/spec/features/order_prices_spec.rb b/frontend/spec/features/order_prices_spec.rbindex 618d081ddf..28ca5eb0bf 100644--- a/frontend/spec/features/order_prices_spec.rb+++ b/frontend/spec/features/order_prices_spec.rb@@ -6,8 +6,7 @@ xdescribe 'Order', type: :feature, js: true dobefore doreset_spree_preferences do |config|- config.allow_currency_change = true- config.show_currency_selector = true+ config.show_store_selector = trueendcreate(:price, variant: product.master, currency: 'EUR', amount: 16.00)diff --git a/frontend/spec/features/product_prices_spec.rb b/frontend/spec/features/product_prices_spec.rbindex 7304bb6354..35686247da 100644--- a/frontend/spec/features/product_prices_spec.rb+++ b/frontend/spec/features/product_prices_spec.rb@@ -8,8 +8,7 @@ describe 'Product with prices in multiple currencies', type: :feature, js: truebefore doreset_spree_preferences do |config|- config.allow_currency_change = true- config.show_currency_selector = true+ config.show_store_selector = trueendcreate(:price, variant: product.master, currency: 'EUR', amount: 16.00)create(:price, variant: product.master, currency: 'GBP', amount: 23.00)@@ -24,11 +23,10 @@ describe 'Product with prices in multiple currencies', type: :feature, js: trueexpect(page).to have_text '£23.00'end- context 'and :show_currency_selector is false' do+ context 'and :show_store_selector is false' dobefore doreset_spree_preferences do |config|- config.allow_currency_change = true- config.show_currency_selector = false+ config.show_store_selector = falseendend@@ -38,23 +36,6 @@ describe 'Product with prices in multiple currencies', type: :feature, js: trueexpect(page).to_not have_text 'Currency'endend-- context 'and :allow_currency_change is false' do- context 'and show_currency_selector is true' do- before do- reset_spree_preferences do |config|- config.allow_currency_change = false- config.show_currency_selector = true- end- end-- it 'will not render the currency selector' do- visit spree.product_path(product)- expect(page).to have_current_path(spree.product_path(product))- expect(page).to_not have_text 'Currency'- end- end- endendend