Skip to content

armgit / spree

Public Imported from GitHub
0

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.

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.rb
index dde191c10e..4a227725d3 100644
--- a/core/app/finders/spree/products/find.rb
+++ b/core/app/finders/spree/products/find.rb
@@ -103,15 +103,15 @@ module Spree
where(
spree_prices: {
amount: price.min..price.max,
- currency: currency
+ currency: currency.upcase
}
)
end
def 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 })
end
def by_taxons(products)
diff --git a/core/app/models/concerns/spree/product_scopes.rb b/core/app/models/concerns/spree/product_scopes.rb
index 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 Spree
search_scopes << :available
def self.active(currency = nil)
- available(nil, currency)
+ available(nil, currency&.upcase)
end
search_scopes << :active
diff --git a/core/app/models/spree/price.rb b/core/app/models/spree/price.rb
index 5c8189f69e..73e3cffde0 100644
--- a/core/app/models/spree/price.rb
+++ b/core/app/models/spree/price.rb
@@ -27,7 +27,7 @@ module Spree
self.whitelisted_ransackable_attributes = ['amount', 'compare_at_amount']
def money
- Spree::Money.new(amount || 0, currency: currency)
+ Spree::Money.new(amount || 0, currency: currency.upcase)
end
def amount=(amount)
diff --git a/core/app/models/spree/variant.rb b/core/app/models/spree/variant.rb
index ce5005b073..c461dffc61 100644
--- a/core/app/models/spree/variant.rb
+++ b/core/app/models/spree/variant.rb
@@ -192,7 +192,7 @@ module Spree
end
def 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)
end
def amount_in(currency)
diff --git a/core/lib/spree/core/controller_helpers/currency.rb b/core/lib/spree/core/controller_helpers/currency.rb
index 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 Spree
params[:currency]
else
current_store.default_currency
- end
+ end.upcase
end
def supported_currencies
@@ -37,7 +37,7 @@ module Spree
end
def supported_currency?(currency_iso_code)
- supported_currencies.map(&:iso_code).include?(currency_iso_code)
+ supported_currencies.map(&:iso_code).include?(currency_iso_code.upcase)
end
end
end
diff --git a/core/lib/spree/core/controller_helpers/search.rb b/core/lib/spree/core/controller_helpers/search.rb
index 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 Spree
def 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&.upcase
end
end
end