Skip to content

Commit

Permalink
Refactor definition of environment.promotions preference
Browse files Browse the repository at this point in the history
There's no need to redefine it as Spree::Core::Environment::Promotions
since it's already that thing, see it's initializer in
core/lib/spree/core/environment.rb and that's exactly what we
are already doing with calculators.
  • Loading branch information
kennyadsl committed Jul 9, 2019
1 parent 949dcef commit a3d639f
Showing 1 changed file with 25 additions and 27 deletions.
52 changes: 25 additions & 27 deletions core/lib/spree/app_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -499,33 +499,31 @@ def environment
Spree::PaymentMethod::Check
]

env.promotions = Spree::Core::Environment::Promotions.new.tap do |promos|
promos.rules = %w[
Spree::Promotion::Rules::ItemTotal
Spree::Promotion::Rules::Product
Spree::Promotion::Rules::User
Spree::Promotion::Rules::FirstOrder
Spree::Promotion::Rules::UserLoggedIn
Spree::Promotion::Rules::OneUsePerUser
Spree::Promotion::Rules::Taxon
Spree::Promotion::Rules::NthOrder
Spree::Promotion::Rules::OptionValue
Spree::Promotion::Rules::FirstRepeatPurchaseSince
Spree::Promotion::Rules::UserRole
Spree::Promotion::Rules::Store
]

promos.actions = %w[
Spree::Promotion::Actions::CreateAdjustment
Spree::Promotion::Actions::CreateItemAdjustments
Spree::Promotion::Actions::CreateQuantityAdjustments
Spree::Promotion::Actions::FreeShipping
]

promos.shipping_actions = %w[
Spree::Promotion::Actions::FreeShipping
]
end
env.promotions.rules = %w[
Spree::Promotion::Rules::ItemTotal
Spree::Promotion::Rules::Product
Spree::Promotion::Rules::User
Spree::Promotion::Rules::FirstOrder
Spree::Promotion::Rules::UserLoggedIn
Spree::Promotion::Rules::OneUsePerUser
Spree::Promotion::Rules::Taxon
Spree::Promotion::Rules::NthOrder
Spree::Promotion::Rules::OptionValue
Spree::Promotion::Rules::FirstRepeatPurchaseSince
Spree::Promotion::Rules::UserRole
Spree::Promotion::Rules::Store
]

env.promotions.actions = %w[
Spree::Promotion::Actions::CreateAdjustment
Spree::Promotion::Actions::CreateItemAdjustments
Spree::Promotion::Actions::CreateQuantityAdjustments
Spree::Promotion::Actions::FreeShipping
]

env.promotions.shipping_actions = %w[
Spree::Promotion::Actions::FreeShipping
]

env.calculators.promotion_actions_create_adjustments = %w[
Spree::Calculator::FlatPercentItemTotal
Expand Down

0 comments on commit a3d639f

Please sign in to comment.