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.

Remove another batch of rails storefront features from core (#13748)

Damian Legawiec94b219fb328e
diff --git a/docs/developer/core-concepts/stores.mdx b/docs/developer/core-concepts/stores.mdx
index 0e5af2150a..2cd4f3d160 100644
--- a/docs/developer/core-concepts/stores.mdx
+++ b/docs/developer/core-concepts/stores.mdx
@@ -54,9 +54,7 @@ erDiagram
| `seo_title` | Custom SEO title |
| `customer_support_email` | Email for customer support inquiries |
| `mail_from_address` | Sender address for transactional emails |
-| `favicon_image_url` | URL to the store's favicon |
| `logo_image_url` | URL to the store's logo |
-| `social_image_url` | URL to the store's social sharing image |
| `facebook`, `twitter`, `instagram` | Social media links |
| `payment_methods` | Payment methods available in this store |
diff --git a/spree/admin/app/helpers/spree/admin/stores_helper.rb b/spree/admin/app/helpers/spree/admin/stores_helper.rb
index f5490c436b..1f2be99f0f 100644
--- a/spree/admin/app/helpers/spree/admin/stores_helper.rb
+++ b/spree/admin/app/helpers/spree/admin/stores_helper.rb
@@ -17,7 +17,7 @@ module Spree
Rails.cache.fetch(["#{store.cache_key_with_version}/admin_icon", opts.to_param]) do
if store.logo&.attached? && store.logo&.variable?
spree_image_tag(store.logo, class: opts[:class], width: opts[:width], height: opts[:height])
- elsif store.favicon_image&.attached? && store.favicon_image&.variable?
+ elsif store.respond_to?(:favicon_image) && store.favicon_image&.attached? && store.favicon_image&.variable?
spree_image_tag(store.favicon_image, class: opts[:class], width: opts[:width], height: opts[:height])
else
first_letter_icon(store.name, opts)
diff --git a/spree/core/app/models/spree/store.rb b/spree/core/app/models/spree/store.rb
index 897039ab00..0f384a2cad 100644
--- a/spree/core/app/models/spree/store.rb
+++ b/spree/core/app/models/spree/store.rb
@@ -41,9 +41,6 @@ module Spree
preference :unit_system, :string, default: 'imperial'
# email preferences
preference :send_consumer_transactional_emails, :boolean, default: true
- # SEO preferences
- preference :index_in_search_engines, :boolean, default: false
- preference :password_protected, :boolean, default: false
# Checkout preferences
preference :guest_checkout, :boolean, default: true
preference :special_instructions_enabled, :boolean, default: false
@@ -110,18 +107,6 @@ module Spree
has_many :api_keys, class_name: 'Spree::ApiKey', dependent: :destroy
- #
- # ActionText
- #
- has_rich_text :customer_terms_of_service
- has_rich_text :customer_privacy_policy
- has_rich_text :customer_returns_policy
- has_rich_text :customer_shipping_policy
-
- #
- # Virtual attributes
- #
- store_accessor :private_metadata, :storefront_password
#
# Validations
@@ -139,14 +124,12 @@ module Spree
connection.column_exists?(:spree_stores, :new_order_notifications_email)
validates :new_order_notifications_email, email: { allow_blank: true }
end
- validates :favicon_image, :social_image, :mailer_logo, content_type: Rails.application.config.active_storage.web_image_content_types
+ validates :mailer_logo, content_type: Rails.application.config.active_storage.web_image_content_types
#
# Attachments
#
has_one_attached :logo, service: Spree.public_storage_service_name
- has_one_attached :favicon_image, service: Spree.public_storage_service_name
- has_one_attached :social_image, service: Spree.public_storage_service_name
has_one_attached :mailer_logo, service: Spree.public_storage_service_name
#
@@ -230,16 +213,6 @@ module Spree
@default_country_for_market = country
end
- def seo_meta_description
- if meta_description.present?
- meta_description
- elsif seo_title.present?
- seo_title
- else
- name
- end
- end
-
def unique_name
@unique_name ||= "#{name} (#{code})"
end
@@ -345,12 +318,6 @@ module Spree
users
end
- def favicon
- return unless favicon_image.attached? && favicon_image.variable?
-
- favicon_image.variant(resize_to_limit: [32, 32])
- end
-
def metric_unit_system?
preferred_unit_system == 'metric'
end
@@ -363,14 +330,6 @@ module Spree
@digital_shipping_category ||= ShippingCategory.find_or_create_by(name: 'Digital')
end
- %w[customer_terms_of_service customer_privacy_policy customer_returns_policy customer_shipping_policy].each do |policy_method|
- define_method policy_method do
- Spree::Deprecation.warn("Store##{policy_method} is deprecated and will be removed in Spree 5.5. Please use Store#policies instead.")
-
- ActionText::RichText.find_by(name: policy_method, record: self)
- end
- end
-
private
def ensure_default_market
diff --git a/spree/core/lib/spree/permitted_attributes.rb b/spree/core/lib/spree/permitted_attributes.rb
index cd9fad9603..3e89570a94 100644
--- a/spree/core/lib/spree/permitted_attributes.rb
+++ b/spree/core/lib/spree/permitted_attributes.rb
@@ -266,15 +266,13 @@ module Spree
:meta_description, :default_currency, :default_country_iso, :mail_from_address,
:customer_support_email, :description, :address, :contact_phone,
:supported_locales, :default_locale, :supported_currencies,
- :new_order_notifications_email, :seo_robots,
+ :new_order_notifications_email,
:preferred_admin_locale, :preferred_timezone, :preferred_weight_unit, :preferred_unit_system,
:preferred_digital_asset_authorized_clicks, :preferred_digital_asset_authorized_days,
:preferred_limit_digital_download_count, :preferred_limit_digital_download_days,
:preferred_digital_asset_link_expire_time,
- :logo, :mailer_logo, :social_logo, :favicon_image,
- :checkout_message, :preferred_guest_checkout,
- :customer_terms_of_service, :customer_privacy_policy,
- :customer_returns_policy, :customer_shipping_policy]
+ :logo, :mailer_logo,
+ :preferred_guest_checkout]
@@store_credit_attributes = %i[amount currency category_id memo]
diff --git a/spree/core/lib/spree/testing_support/factories/store_factory.rb b/spree/core/lib/spree/testing_support/factories/store_factory.rb
index cac1bfb3a2..8b3c204d47 100644
--- a/spree/core/lib/spree/testing_support/factories/store_factory.rb
+++ b/spree/core/lib/spree/testing_support/factories/store_factory.rb
@@ -14,14 +14,5 @@ FactoryBot.define do
instagram { 'spreecommerce' }
meta_description { 'Sample store description.' }
- trait :with_favicon do
- after(:build) do |store|
- store.favicon_image.attach(
- io: File.open(Spree::Core::Engine.root.join('spec', 'fixtures', 'thinking-cat.jpg')),
- filename: 'thinking-cat.jpg',
- content_type: 'image/jpeg'
- )
- end
- end
end
end
diff --git a/spree/core/lib/tasks/core.rake b/spree/core/lib/tasks/core.rake
index be6e5cab59..bc3140a1ed 100644
--- a/spree/core/lib/tasks/core.rake
+++ b/spree/core/lib/tasks/core.rake
@@ -8,34 +8,6 @@ namespace :db do
end
end
- desc 'Migrate policies to store policies'
- task migrate_policies: :environment do |_t, _args|
- # Helper to consistently derive policy name
- derive_policy_name = lambda do |name_str|
- name_str.to_s.gsub(/customer_/, '').gsub(/_policy$/, '')
- end
-
- # Check if migration has already been run
- if Spree::Policy.any?
- puts "Policies already exist. Skipping migration to prevent duplicates."
- exit
- end
-
- Spree::Store.all.each do |store|
- %w[customer_terms_of_service customer_privacy_policy customer_returns_policy customer_shipping_policy].each do |policy_slug|
- policy = store.send(policy_slug)
- next unless policy.present?
-
- store.policies.create(
- name: Spree.t(derive_policy_name.call(policy_slug)),
- body: policy.body
- )
-
- puts "Migrated #{policy_slug} to store #{store.id}"
- end
- end
- end
-
end
namespace :core do
diff --git a/spree/core/spec/models/spree/store_spec.rb b/spree/core/spec/models/spree/store_spec.rb
index 55dafd69f0..4305408837 100644
--- a/spree/core/spec/models/spree/store_spec.rb
+++ b/spree/core/spec/models/spree/store_spec.rb
@@ -739,28 +739,6 @@ describe Spree::Store, type: :model, without_global_store: true do
end
end
- describe '#favicon' do
- subject(:favicon) { store.favicon }
-
- context 'with an attached favicon image' do
- let(:store) { create(:store, :with_favicon) }
- let(:favicon_variation) { favicon.processed.variation }
-
- it 'returns a resized favicon' do
- expect(favicon_variation).to be_present
- expect(favicon_variation.transformations.fetch(:resize_to_limit)).to eq([32, 32])
- end
- end
-
- context 'without an attached favicon image' do
- let(:store) { build(:store) }
-
- it 'returns a blank favicon' do
- expect(favicon).to be_nil
- end
- end
- end
-
describe 'soft deletion' do
let!(:store) { create(:store) }