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.

Let a tax provider register itself from an initializer

Łukasz Adamczyk4ef1ed1a4d1f
diff --git a/spree/core/lib/spree/core/engine.rb b/spree/core/lib/spree/core/engine.rb
index ed524def7b..9240821296 100644
--- a/spree/core/lib/spree/core/engine.rb
+++ b/spree/core/lib/spree/core/engine.rb
@@ -127,6 +127,12 @@ module Spree
app.config.spree.delivery_rate_providers = []
end
+ # Same reason again: a tax provider gem, or a host app, registers its
+ # engine from an initializer file. Core's Internal concatenates below.
+ initializer 'spree.register.tax_providers', before: :load_config_initializers do |app|
+ app.config.spree.tax_providers = []
+ end
+
initializer 'spree.register.delivery_profile_types', before: :load_config_initializers do |app|
app.config.spree.delivery_profile_types = []
end
@@ -184,10 +190,13 @@ module Spree
]
# The fallback engine when a market names none (see docs/plans/6.0-tax-provider.md).
- Rails.application.config.spree.default_tax_provider = Spree::TaxProvider::Internal
+ # Assigned only if an initializer file has not already named one — an app
+ # that picks its own default must keep it.
+ Rails.application.config.spree.default_tax_provider ||= Spree::TaxProvider::Internal
- # Engines a market can select. Provider gems append their own.
- Rails.application.config.spree.tax_providers = [Spree::TaxProvider::Internal]
+ # Engines a market can select. Concatenated, not assigned: provider gems
+ # and host apps append theirs from initializer files, which run first.
+ Rails.application.config.spree.tax_providers.concat [Spree::TaxProvider::Internal]
# Password policy for the default auth models. Swap for corporate rules,
# breach-list lookups or entropy scoring.