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

[v4.4] Only set promo configuration to legacy if no other set #6019

Merged
merged 1 commit into from
Dec 6, 2024
Merged
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
11 changes: 8 additions & 3 deletions legacy_promotions/lib/solidus_legacy_promotions/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,17 @@ class Engine < ::Rails::Engine
end

initializer "solidus_legacy_promotions", after: "spree.load_config_initializers" do
Spree::Config.order_contents_class = "Spree::OrderContents"
Spree::Config.promotions = SolidusLegacyPromotions::Configuration.new
Spree::Config.adjustment_promotion_source_types << "Spree::PromotionAction"
# Only set these if there is no promotion configuration set. In this case,
# we're running on a store without the new `solidus_promotions` gem and we
# need to set the configuration to the legacy one.
if Spree::Config.promotions.is_a?(Spree::Core::NullPromotionConfiguration)
Spree::Config.order_contents_class = "Spree::OrderContents"
Spree::Config.promotions = SolidusLegacyPromotions::Configuration.new
end

Spree::Api::Config.adjustment_attributes << :promotion_code_id
Spree::Api::Config.adjustment_attributes << :eligible
Spree::Config.adjustment_promotion_source_types << "Spree::PromotionAction"
end
end
end
Loading