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
WIP Extract legacy promotions #5634
base: main
Are you sure you want to change the base?
Conversation
bcaff25
to
be37df1
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5634 +/- ##
==========================================
- Coverage 88.87% 88.81% -0.07%
==========================================
Files 699 705 +6
Lines 16607 16660 +53
==========================================
+ Hits 14760 14797 +37
- Misses 1847 1863 +16 ☔ View full report in Codecov by Sentry. |
We want to be able to move all promotion-related things out of `solidus_core` in PR solidusio#5634. However, Spree::AppConfiguration also does all the promotion-specific things, and we can't move the app configuration out of core. So what this does is it introduces a new configuration object containing those attributes of the core app_configuration class and moves them into a `promotion_configuration` object. This object is now available as Spree::Promotion::Config.
Depends on #5635 |
Thanks for your work on this @mamhoff. Now to find time to actually review it properly... 😅 |
…ration We want to be able to move all promotion-related things out of `solidus_core` in PR solidusio#5634. However, Spree::AppConfiguration also does all the promotion-specific things, and we can't move the app configuration out of core. In solidusio#5658, we've added a promotion configuration object as a nucleus for core's promotion system's configuration, `Spree::Core::PromotionConfiguration`. This implements all the promotion-specific configuration preferences from `Spree::AppConfiguration` there.
…ration We want to be able to move all promotion-related things out of `solidus_core` in PR solidusio#5634. However, Spree::AppConfiguration also does all the promotion-specific things, and we can't move the app configuration out of core. In solidusio#5658, we've added a promotion configuration object as a nucleus for core's promotion system's configuration, `Spree::Core::PromotionConfiguration`. This implements all the promotion-specific configuration preferences from `Spree::AppConfiguration` there.
…ration We want to be able to move all promotion-related things out of `solidus_core` in PR solidusio#5634. However, Spree::AppConfiguration also does all the promotion-specific things, and we can't move the app configuration out of core. In solidusio#5658, we've added a promotion configuration object as a nucleus for core's promotion system's configuration, `Spree::Core::PromotionConfiguration`. This implements all the promotion-specific configuration preferences from `Spree::AppConfiguration` there.
f57fc58
to
ba90efe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😅 I admire your patience
Awesome work.
legacy_promotions/db/migrate/20231031175215_add_promotion_order_promotion_foreign_key.rb
Outdated
Show resolved
Hide resolved
legacy_promotions/spec/mailers/spree/promotion_code_batch_mailer_spec.rb
Outdated
Show resolved
Hide resolved
legacy_promotions/db/migrate/20160101010001_solidus_one_four_promotions.rb
Outdated
Show resolved
Hide resolved
legacy_promotions/db/migrate/20161017102621_create_spree_promotion_code_batch.rb
Outdated
Show resolved
Hide resolved
legacy_promotions/app/decorators/solidus_legacy_promotions/models/spree/order_decorator.rb
Show resolved
Hide resolved
14d959e
to
679f6b6
Compare
8b1a5f9
to
4525f8b
Compare
Spree::OrderContents does promotion-related things and shouldn't. To keep the constant, I remove the parts that do promotion-related things and rename the class, and reintroduce it it solidus_legacy_promotions.
In legacy_promotions, we'll just keep them in `app`, where they're tested, too.
The one example here relies on the legacy promo system.
Spree::Calculator::FlatRate is gone, but luckily, we can just use the shipping equivalent.
We don't need #recalculate for anything in core, and we don´t need the association to promotion codes.
We don't actually have any promotion code in core left, so we need to be using the Null promotion configuration.
I'm keeping the spec to test what the model does, but moving the extended spec with the actual promotion to solidus_legacy_promotions.
With a properly configured promotion system, we don't need a special "shipping" promotion handler. This moves the shipping-specific promotion handling into the solidus_legacy_promotions gem.
We would rather keep `Spree::Order#ensure_promotions_eligible` in core, as what it does is re-run the promotion adjuster class and make sure the amounts are still correct. This should be fine for every promotion system. However, since the Null adjuster doesn't actually do anything, we need to stub what it does in the spec.
This should probably in the future be implemented in an Omnes hook.
This method isn't called anywhere in core, so we're not creating some kidn of configuration endpoint. It's also worthy of deprecation or fixing, as it will return true for canceled orders.
`Spree::PromotionAction` is not in core any longer, and the null promo adjuster can not actually produce any adjustments.
These make references to the old classes and cannot stay in core.
In the future, the admin views for legacy promotions will live in the legacy_promotions gem.
In the future, the admin views for legacy promotions will live in the solidus_legacy_promotions gems. This is just to see if we get a green build.
5bebaa5
to
ab26519
Compare
Summary
This extracts the legacy promotion system into a gem that lives within the solidus codebase. I've talked about this with @kennyadsl as a way to integrate a new solidus_promotions gem later, modeled after solidus_friendly_promotions.
This is still Work in progress, and comments are welcome.
Checklist
The following are mandatory for all PRs:
The following are not always needed: