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
Extract supported_currencies_for_all_stores method to CurrencyHelpers
Damian Legawiec7c04765e419d
diff --git a/backend/app/controllers/spree/admin/prices_controller.rb b/backend/app/controllers/spree/admin/prices_controller.rbindex 5fb8f037a6..4b84b3a887 100644--- a/backend/app/controllers/spree/admin/prices_controller.rb+++ b/backend/app/controllers/spree/admin/prices_controller.rb@@ -3,8 +3,6 @@ module Spreeclass PricesController < ResourceControllerbelongs_to 'spree/product', find_by: :slug- helper_method :supported_currencies_for_all_stores-def createparams.require(:vp).permit!params[:vp].each do |variant_id, prices|@@ -23,17 +21,6 @@ module Spreeflash[:success] = Spree.t('notice_messages.prices_saved')redirect_to admin_product_path(parent)end-- private-- def supported_currencies_for_all_stores- @supported_currencies_for_all_stores = begin- (- Spree::Store.pluck(:supported_currencies).map { |c| c&.split(',') }.flatten + Spree::Store.pluck(:default_currency)- ).- compact.uniq.map { |code| ::Money::Currency.find(code.strip) }- end- endendendenddiff --git a/core/lib/spree/core/controller_helpers/currency_helpers.rb b/core/lib/spree/core/controller_helpers/currency_helpers.rbindex b95f823333..1e8fd309db 100644--- a/core/lib/spree/core/controller_helpers/currency_helpers.rb+++ b/core/lib/spree/core/controller_helpers/currency_helpers.rb@@ -4,11 +4,21 @@ module Spreemodule CurrencyHelpersdef self.included(receiver)receiver.send :helper_method, :supported_currencies+ receiver.send :helper_method, :supported_currencies_for_all_storesenddef supported_currenciescurrent_store.supported_currencies_listend++ def supported_currencies_for_all_stores+ @supported_currencies_for_all_stores ||= begin+ (+ Spree::Store.pluck(:supported_currencies).map { |c| c&.split(',') }.flatten + Spree::Store.pluck(:default_currency)+ ).+ compact.uniq.map { |code| ::Money::Currency.find(code.strip) }+ end+ endendendend