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.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Add unique name to store. (#10568)
Matthew Kennedy8490dc788ee8
diff --git a/backend/app/views/spree/admin/orders/_store_form.html.erb b/backend/app/views/spree/admin/orders/_store_form.html.erbindex ccc5d4af0c..65e56fb654 100644--- a/backend/app/views/spree/admin/orders/_store_form.html.erb+++ b/backend/app/views/spree/admin/orders/_store_form.html.erb@@ -4,7 +4,7 @@<div data-hook="admin_order_store_field"><%= f.field_container :store_id, class: ['form-group'] do %><%= f.label :store_id, Spree.t(:store) %>- <%= f.collection_select(:store_id, @stores, :id, :name, { include_blank: false }, { class: "select2" }) %>+ <%= f.collection_select(:store_id, @stores, :id, :unique_name, { include_blank: false }, { class: "select2" }) %><%= f.error_message_on :store_id %><% end %></div>diff --git a/backend/app/views/spree/admin/payment_methods/_form.html.erb b/backend/app/views/spree/admin/payment_methods/_form.html.erbindex 07fada604d..3b6e0c0ce8 100644--- a/backend/app/views/spree/admin/payment_methods/_form.html.erb+++ b/backend/app/views/spree/admin/payment_methods/_form.html.erb@@ -17,7 +17,7 @@</div><div data-hook="store" class="form-group"><%= label_tag :payment_method_store, Spree.t(:store) %>- <%= collection_select(:payment_method, :store_id, @stores, :id, :name, { include_blank: true }, {id: 'store_id', class: 'select2'}) %>+ <%= collection_select(:payment_method, :store_id, @stores, :id, :unique_name, { include_blank: true }, {id: 'store_id', class: 'select2'}) %></div><div data-hook="display" class="form-group"><%= label_tag :payment_method_display_on, Spree.t(:display) %>diff --git a/backend/app/views/spree/admin/stores/index.html.erb b/backend/app/views/spree/admin/stores/index.html.erbindex 9cfa5fdf32..16982a6d68 100644--- a/backend/app/views/spree/admin/stores/index.html.erb+++ b/backend/app/views/spree/admin/stores/index.html.erb@@ -19,7 +19,7 @@<tbody><% @stores.each do |store| %><tr>- <td><%= store.name %></td>+ <td><%= store.unique_name %></td><td><%= link_to store.url, 'https://' + store.url, target: :blank %></td><td><%= store.default_currency %></td><td><%= store.default ? "<strong>#{Spree.t(:say_yes)}</strong>".html_safe : Spree.t(:say_no) %>diff --git a/core/app/models/spree/store.rb b/core/app/models/spree/store.rbindex 85ac8cc7a5..ef6fe3764f 100644--- a/core/app/models/spree/store.rb+++ b/core/app/models/spree/store.rb@@ -47,6 +47,10 @@ module Spreeend.uniq.compactend+ def unique_name+ "#{name} (#{code})"+ end+privatedef ensure_default_exists_and_is_uniquediff --git a/core/spec/models/spree/store_spec.rb b/core/spec/models/spree/store_spec.rbindex 40a1a03a72..095538889c 100644--- a/core/spec/models/spree/store_spec.rb+++ b/core/spec/models/spree/store_spec.rb@@ -84,6 +84,14 @@ describe Spree::Store, type: :model doendend+ context '.unique_name' do+ let!(:store) { create(:store) }++ it 'returns the Store Name followed by the Store Code in parentheses' do+ expect(store.unique_name).to eq("#{store.name} (#{store.code})")+ end+ end+describe '.supported_currencies_list' docontext 'with supported currencies set' dolet(:currencies) { 'USD, EUR, dummy' }