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.

Fixed: storefront form not overwriting `store.name` (#13005)

Damian Legawiecfad63a690c38
diff --git a/admin/app/controllers/spree/admin/storefront_controller.rb b/admin/app/controllers/spree/admin/storefront_controller.rb
index 9a93775f4e..8c2fd358af 100644
--- a/admin/app/controllers/spree/admin/storefront_controller.rb
+++ b/admin/app/controllers/spree/admin/storefront_controller.rb
@@ -26,7 +26,7 @@ module Spree
params.require(:store).permit(
:preferred_index_in_search_engines,
:preferred_password_protected, :social_image, :favicon_image, :name,
- :meta_description, :meta_title, :meta_keywords, :seo_robots,
+ :meta_description, :meta_keywords, :seo_robots, :seo_title,
:facebook, :twitter, :instagram, :linkedin, :youtube, :tiktok, :pinterest,
:storefront_custom_code_head, :storefront_custom_code_body_start,
:storefront_custom_code_body_end, :storefront_password, :spotify, :discord
diff --git a/admin/app/views/spree/admin/storefront/edit.html.erb b/admin/app/views/spree/admin/storefront/edit.html.erb
index 712c3a0671..d5a94b7e6e 100644
--- a/admin/app/views/spree/admin/storefront/edit.html.erb
+++ b/admin/app/views/spree/admin/storefront/edit.html.erb
@@ -26,18 +26,9 @@
</h5>
</div>
<div class="card-body">
- <div class="form-group">
- <%= f.label :name, Spree.t(:site_name) %>
- <%= f.text_field :name, class: 'form-control' %>
- </div>
- <%= f.spree_text_area :meta_description, label: 'Search description', style: 'min-height: 5em' %>
- <div class="custom-control custom-checkbox mb-2">
- <%= f.check_box :preferred_index_in_search_engines, class: 'custom-control-input' %>
- <%= f.label :preferred_index_in_search_engines, Spree.t(:index_in_search_engines), class: 'custom-control-label' %>
- </div>
- <p class="text-muted small pl-4 mb-0">
- Checking this box will allow your site to appear in search engines.
- </p>
+ <%= f.spree_text_field :seo_title %>
+ <%= f.spree_text_area :meta_description %>
+ <%= f.spree_check_box :preferred_index_in_search_engines, label: Spree.t(:index_in_search_engines), help: 'Checking this box will allow your site to appear in search engines.' %>
</div>
</div>
@@ -48,17 +39,9 @@
</h5>
</div>
<div class="card-body" data-controller="reveal" data-reveal-hidden-class="d-none">
- <div class="custom-control custom-checkbox mb-2">
- <%= f.check_box :preferred_password_protected, class: 'custom-control-input', data: { action: 'reveal#toggle' } %>
- <%= f.label :preferred_password_protected, Spree.t(:password_protected), class: 'custom-control-label' %>
- </div>
- <p class="text-muted small pl-4">
- Checking this box will put your storefront behind a password.
- </p>
-
- <div class="form-group <%= @store.prefers_password_protected? ? '' : 'd-none' %>" data-reveal-target="item">
- <%= f.label :storefront_password, Spree.t(:password) %>
- <%= f.text_field :storefront_password, class: 'form-control' %>
+ <%= f.spree_check_box :preferred_password_protected, label: Spree.t(:password_protected), help: 'Checking this box will put your storefront behind a password.', data: { action: 'reveal#toggle' } %>
+ <div class="d-none" data-reveal-target="item">
+ <%= f.spree_text_field :storefront_password, label: Spree.t(:password), help: 'Enter a password to protect your storefront.' %>
</div>
</div>
</div>
@@ -71,9 +54,7 @@
</div>
<div class="card-body">
<%= f.spree_text_area :storefront_custom_code_head, rows: 4 %>
-
<%= f.spree_text_area :storefront_custom_code_body_start, rows: 4 %>
-
<%= f.spree_text_area :storefront_custom_code_body_end, rows: 4 %>
</div>
</div>
@@ -114,16 +95,7 @@
Social links will be displayed in the footer of your store
</div>
<% Spree::Store::SUPPORTED_SOCIAL_NETWORKS.each do |social| %>
- <div class="form-group">
- <%= f.label :"store_#{social}" do %>
- <%= icon social %>
- <%= social.capitalize %>
- <% end %>
- <%= f.text_field social.to_sym,
- class: 'form-control',
- placeholder: Spree::Store::SOCIAL_NETWORKS_CONFIG[social.to_sym][:input_placeholder]
- %>
- </div>
+ <%= f.spree_text_field social.to_sym, label: social.capitalize, placeholder: Spree::Store::SOCIAL_NETWORKS_CONFIG[social.to_sym][:input_placeholder] %>
<% end %>
</div>
</div>
diff --git a/admin/spec/controllers/spree/admin/storefront_controller_spec.rb b/admin/spec/controllers/spree/admin/storefront_controller_spec.rb
index 7f4a0be8d6..bca28fd910 100644
--- a/admin/spec/controllers/spree/admin/storefront_controller_spec.rb
+++ b/admin/spec/controllers/spree/admin/storefront_controller_spec.rb
@@ -21,7 +21,7 @@ describe Spree::Admin::StorefrontController do
let(:store_params) do
{
- name: 'New Store Name',
+ seo_title: 'New Store Name',
meta_description: 'This is a cool store',
storefront_password: 'password',
facebook: 'https://www.facebook.com/spreecommerce',
@@ -40,7 +40,7 @@ describe Spree::Admin::StorefrontController do
it 'updates the store data' do
subject
- expect(store.reload.name).to eq('New Store Name')
+ expect(store.reload.seo_title).to eq('New Store Name')
expect(store.meta_description).to eq('This is a cool store')
expect(store.storefront_password).to eq('password')
expect(store.facebook).to eq('https://www.facebook.com/spreecommerce')
diff --git a/core/config/locales/en.yml b/core/config/locales/en.yml
index 15ae3ce062..629f90e363 100644
--- a/core/config/locales/en.yml
+++ b/core/config/locales/en.yml
@@ -165,6 +165,9 @@ en:
preferred_limit_digital_download_days: Limit digital links download days
seo_robots: SEO Robots
seo_title: SEO Title
+ storefront_custom_code_body_end: Custom Code before closing body tag
+ storefront_custom_code_body_start: Custom Code after opening body tag
+ storefront_custom_code_head: Custom Code in page head
url: Site URL
spree/store_credit:
amount_used: Amount used
diff --git a/storefront/app/controllers/spree/store_controller.rb b/storefront/app/controllers/spree/store_controller.rb
index dd961c590a..042c6b39a1 100644
--- a/storefront/app/controllers/spree/store_controller.rb
+++ b/storefront/app/controllers/spree/store_controller.rb
@@ -114,7 +114,7 @@ module Spree
end
def default_title
- @default_title ||= current_store.name
+ @default_title ||= current_store.seo_title.presence || current_store.name
end
# this is a hook for subclasses to provide title