mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-31 21:37:16 +00:00
Initialize custom calculators using Spree API
Freely inspired by https://github.com/coopdevs/spree/blob/2-0-stable/core/lib/spree/core/engine.rb#L78
This commit is contained in:
committed by
Rob Harrington
parent
cf4bd8d755
commit
23585e6ea8
@@ -25,20 +25,25 @@ module Openfoodnetwork
|
||||
end
|
||||
|
||||
# Register Spree calculators
|
||||
initializer "spree.register.calculators" do |app|
|
||||
initializer 'spree.register.calculators' do |app|
|
||||
app.config.spree.calculators.shipping_methods << OpenFoodNetwork::Calculator::Weight
|
||||
|
||||
app.config.spree.calculators.enterprise_fees = [Calculator::FlatPercentPerItem,
|
||||
Spree::Calculator::FlatRate,
|
||||
Spree::Calculator::FlexiRate,
|
||||
Spree::Calculator::PerItem,
|
||||
Spree::Calculator::PriceSack,
|
||||
OpenFoodNetwork::Calculator::Weight]
|
||||
app.config.spree.calculators.payment_methods = [Spree::Calculator::FlatPercentItemTotal,
|
||||
Spree::Calculator::FlatRate,
|
||||
Spree::Calculator::FlexiRate,
|
||||
Spree::Calculator::PerItem,
|
||||
Spree::Calculator::PriceSack]
|
||||
app.config.spree.calculators.add_class('enterprise_fees')
|
||||
config.spree.calculators.enterprise_fees = [
|
||||
Calculator::FlatPercentPerItem,
|
||||
Spree::Calculator::FlatRate,
|
||||
Spree::Calculator::FlexiRate,
|
||||
Spree::Calculator::PerItem,
|
||||
Spree::Calculator::PriceSack,
|
||||
OpenFoodNetwork::Calculator::Weight
|
||||
]
|
||||
app.config.spree.calculators.add_class('payment_methods')
|
||||
config.spree.calculators.payment_methods = [
|
||||
Spree::Calculator::FlatPercentItemTotal,
|
||||
Spree::Calculator::FlatRate,
|
||||
Spree::Calculator::FlexiRate,
|
||||
Spree::Calculator::PerItem,
|
||||
Spree::Calculator::PriceSack
|
||||
]
|
||||
end
|
||||
|
||||
# Register Spree payment methods
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
# In order to initialize a setting do:
|
||||
# config.setting_name = 'new value'
|
||||
|
||||
|
||||
require 'spree/product_filters'
|
||||
require 'spree/core/calculated_adjustments_decorator'
|
||||
|
||||
@@ -41,17 +40,6 @@ end
|
||||
module OpenFoodNetwork
|
||||
end
|
||||
|
||||
# Add calculators category for enterprise fees
|
||||
module Spree
|
||||
module Core
|
||||
class Environment
|
||||
class Calculators
|
||||
attr_accessor :enterprise_fees, :payment_methods
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Forcing spree to always allow SSL connections
|
||||
# Since we are using config.force_ssl = true
|
||||
# Without this we get a redirect loop: see https://groups.google.com/forum/#!topic/spree-user/NwpqGxJ4klk
|
||||
|
||||
Reference in New Issue
Block a user