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 Admin Panel Address form to include all countries for more flexbility

Damian Legawiec7c8003d2681b
diff --git a/backend/app/views/spree/admin/shared/_address_form.html.erb b/backend/app/views/spree/admin/shared/_address_form.html.erb
index 2a2bfae47c..c98426ee03 100644
--- a/backend/app/views/spree/admin/shared/_address_form.html.erb
+++ b/backend/app/views/spree/admin/shared/_address_form.html.erb
@@ -5,7 +5,7 @@
<%= field_container (s_or_b + '_' + field), nil, class: ["form-group", "#{type}-row"] do %>
<%= f.label :country_id, Spree.t(:country) %>
<div id="<%= s_or_b %>country">
- <%= f.collection_select :country_id, available_countries, :id, :name, {}, { class: 'select2 w-100' } %>
+ <%= f.collection_select :country_id, all_countries, :id, :name, {}, { class: 'select2 w-100' } %>
</div>
<% end %>
<% elsif field == "state" %>
diff --git a/core/app/helpers/spree/base_helper.rb b/core/app/helpers/spree/base_helper.rb
index 141a30d5d5..7bfad08180 100644
--- a/core/app/helpers/spree/base_helper.rb
+++ b/core/app/helpers/spree/base_helper.rb
@@ -9,6 +9,15 @@ module Spree
end.sort_by { |c| c.name.parameterize }
end
+ def all_countries
+ countries = Spree::Country.all
+
+ countries.collect do |country|
+ country.name = Spree.t(country.iso, scope: 'country_names', default: country.name)
+ country
+ end.sort_by { |c| c.name.parameterize }
+ end
+
def display_price(product_or_variant)
product_or_variant.
price_in(current_currency).