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.

Improve `Store#supported_currencies_list`

Damian Legawieca38e72f37753
diff --git a/core/app/models/spree/store.rb b/core/app/models/spree/store.rb
index 3c40718445..396f20f35e 100644
--- a/core/app/models/spree/store.rb
+++ b/core/app/models/spree/store.rb
@@ -176,9 +176,9 @@ module Spree
end
def supported_currencies_list
- @supported_currencies_list ||= (read_attribute(:supported_currencies).to_s.split(',') << default_currency).map(&:to_s).map do |code|
+ @supported_currencies_list ||= ([default_currency] + read_attribute(:supported_currencies).to_s.split(',')).uniq.map(&:to_s).map do |code|
::Money::Currency.find(code.strip)
- end.uniq.compact.sort_by { |currency| currency.iso_code == default_currency ? 0 : 1 }
+ end.compact.sort_by { |currency| currency.iso_code == default_currency ? 0 : 1 }
end
def homepage(requested_locale)
@@ -221,6 +221,10 @@ module Spree
url
end
+ def formatted_url_or_custom_domain
+ formatted_url
+ end
+
def countries_available_for_checkout
@countries_available_for_checkout ||= Rails.cache.fetch(countries_available_for_checkout_cache_key) do
checkout_zone.try(:country_list) || Spree::Country.all