Skip to content

Commit

Permalink
BUGFIX: engine initialization prevented overrides in Solidus v4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
boomer196 committed Dec 16, 2024
1 parent 1c16be1 commit f09e397
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ end

Example:
```ruby
Spree::DigitalConfiguration[:authorized_clicks] = nil # infinite access for user
Rails.application.config.after_initialize do
Spree::DigitalConfiguration[:authorized_clicks] = nil # infinite access for user
end
```

### DRM
Expand Down
16 changes: 10 additions & 6 deletions lib/solidus_digital/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ class Engine < Rails::Engine
app.autoloaders.main.ignore(root.join('app/overrides'))
end

initializer "spree.register.digital_shipping" do |app|
Rails.application.config.after_initialize do
::Spree::DigitalConfiguration = ::Spree::SpreeDigitalConfiguration.new
app.config.spree.calculators.shipping_methods << ::Spree::Calculator::Shipping::DigitalDelivery
app.config.spree.stock_splitters << ::Spree::Stock::Splitter::DigitalSplitter
end
initializer "solidus_digital.preferences", before: "spree.environment" do |_app|
::Spree::DigitalConfiguration = ::Spree::SpreeDigitalConfiguration.new
end

initializer "solidus_digital.digital_shipping", after: "spree.environment" do |app|
app.config.spree.calculators.shipping_methods << "Spree::Calculator::Shipping::DigitalDelivery"
end

initializer "solidus_digital.digital_splitter", after: "spree.environment" do |app|
app.config.spree.stock_splitters << "Spree::Stock::Splitter::DigitalSplitter"
end

# use rspec for tests
Expand Down

0 comments on commit f09e397

Please sign in to comment.