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.

Fix and deprecate AddressHelper internal methods that we won't use an… (#13086)

Damian Legawiecdf9cff7c2889
diff --git a/core/app/helpers/spree/addresses_helper.rb b/core/app/helpers/spree/addresses_helper.rb
index dfa120aab8..1fb227babf 100644
--- a/core/app/helpers/spree/addresses_helper.rb
+++ b/core/app/helpers/spree/addresses_helper.rb
@@ -67,16 +67,22 @@ module Spree
end
def current_store_countries_with_states_ids
- @current_store_countries_with_states_ids ||= current_store.countries_available_for_checkout.where(states_required: true).includes(:states).each_with_object([]) do |country, memo|
+ Spree::Deprecation.warn('current_store_countries_with_states_ids is deprecated and will be removed in Spree 5.3')
+
+ @current_store_countries_with_states_ids ||= current_store.countries_available_for_checkout.find_all { |country| country.states_required? }.each_with_object([]) do |country, memo|
memo << current_store.states_available_for_checkout(country)
end.flatten.pluck(:country_id)
end
def current_store_countries_without_states_ids
- @current_store_countries_without_states_ids ||= current_store.countries_available_for_checkout.where(states_required: false).ids
+ Spree::Deprecation.warn('current_store_countries_without_states_ids is deprecated and will be removed in Spree 5.3')
+
+ @current_store_countries_without_states_ids ||= current_store.countries_available_for_checkout.find_all { |country| !country.states_required? }.pluck(:id)
end
def current_store_supported_countries_ids
+ Spree::Deprecation.warn('current_store_supported_countries_ids is deprecated and will be removed in Spree 5.3')
+
@current_store_supported_countries_ids ||= Rails.cache.fetch(['current_store_supported_countries_ids', current_store]) do
(current_store_countries_with_states_ids + current_store_countries_without_states_ids).uniq
end
@@ -90,7 +96,7 @@ module Spree
addresses.
includes(:country, :state).
not_quick_checkout.
- where(country_id: current_store_supported_countries_ids).
+ where(country_id: current_store.countries_available_for_checkout.pluck(:id)).
includes(:user)
end
end