Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUGFIX: engine initialization prevented overrides in Solidus v4.4 #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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