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
Always use upcased version of currency (iso format)
Damian Legawiec17b48f3dac73
diff --git a/core/app/finders/spree/products/find.rb b/core/app/finders/spree/products/find.rbindex dde191c10e..4a227725d3 100644--- a/core/app/finders/spree/products/find.rb+++ b/core/app/finders/spree/products/find.rb@@ -103,15 +103,15 @@ module Spreewhere(spree_prices: {amount: price.min..price.max,- currency: currency+ currency: currency.upcase})enddef by_currency(products)- return products unless currency?+ return products if price?- products.joins(master: :prices).where(spree_prices: { currency: currency })+ products.joins(master: :prices).where(spree_prices: { currency: currency.upcase })enddef by_taxons(products)diff --git a/core/app/models/concerns/spree/product_scopes.rb b/core/app/models/concerns/spree/product_scopes.rbindex b7d41ad3ba..f5d1bd01d3 100644--- a/core/app/models/concerns/spree/product_scopes.rb+++ b/core/app/models/concerns/spree/product_scopes.rb@@ -206,7 +206,7 @@ module Spreesearch_scopes << :availabledef self.active(currency = nil)- available(nil, currency)+ available(nil, currency&.upcase)endsearch_scopes << :activediff --git a/core/app/models/spree/price.rb b/core/app/models/spree/price.rbindex 5c8189f69e..73e3cffde0 100644--- a/core/app/models/spree/price.rb+++ b/core/app/models/spree/price.rb@@ -27,7 +27,7 @@ module Spreeself.whitelisted_ransackable_attributes = ['amount', 'compare_at_amount']def money- Spree::Money.new(amount || 0, currency: currency)+ Spree::Money.new(amount || 0, currency: currency.upcase)enddef amount=(amount)diff --git a/core/app/models/spree/variant.rb b/core/app/models/spree/variant.rbindex ce5005b073..c461dffc61 100644--- a/core/app/models/spree/variant.rb+++ b/core/app/models/spree/variant.rb@@ -192,7 +192,7 @@ module Spreeenddef price_in(currency)- prices.detect { |price| price.currency == currency } || prices.build(currency: currency)+ prices.detect { |price| price.currency == currency.upcase } || prices.build(currency: currency.upcase)enddef amount_in(currency)diff --git a/core/lib/spree/core/controller_helpers/currency.rb b/core/lib/spree/core/controller_helpers/currency.rbindex fb358e1639..8a4af7a89a 100644--- a/core/lib/spree/core/controller_helpers/currency.rb+++ b/core/lib/spree/core/controller_helpers/currency.rb@@ -20,7 +20,7 @@ module Spreeparams[:currency]elsecurrent_store.default_currency- end+ end.upcaseenddef supported_currencies@@ -37,7 +37,7 @@ module Spreeenddef supported_currency?(currency_iso_code)- supported_currencies.map(&:iso_code).include?(currency_iso_code)+ supported_currencies.map(&:iso_code).include?(currency_iso_code.upcase)endendenddiff --git a/core/lib/spree/core/controller_helpers/search.rb b/core/lib/spree/core/controller_helpers/search.rbindex ee2356e5fd..5c09ccf900 100644--- a/core/lib/spree/core/controller_helpers/search.rb+++ b/core/lib/spree/core/controller_helpers/search.rb@@ -5,7 +5,7 @@ module Spreedef build_searcher(params)Spree::Config.searcher_class.new(params).tap do |searcher|searcher.current_user = try_spree_current_user- searcher.current_currency = current_currency+ searcher.current_currency = current_currency&.upcaseendendend