Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List all available countries in checkout instead of all countries (even if not listed in any Zone). #11711

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 12 additions & 1 deletion core/app/models/spree/store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def formatted_url
end

def countries_available_for_checkout
@countries_available_for_checkout ||= checkout_zone.try(:country_list) || Spree::Country.all
@countries_available_for_checkout ||= checkout_zone.try(:country_list) || all_available_countries
end

def states_available_for_checkout(country)
Expand All @@ -192,6 +192,17 @@ def can_be_deleted?

private

def all_available_countries
zones = Spree::Zone.all.to_a
if zones.empty?
Spree::Country.all
else
zones.each_with_object([]) do |zone, a|
a.concat(zone.country_list)
end
end
end

def ensure_default_exists_and_is_unique
if default
Store.where.not(id: id).update_all(default: false)
Expand Down