-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add order_recalculated event #3553
Add order_recalculated event #3553
Conversation
e079812
to
869e71c
Compare
869e71c
to
d5a4358
Compare
d5a4358
to
0894a1f
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.
@spaghetticode thanks! It's great to see more events in the codebase. I left a couple of small comments, and the rest looks good.
0894a1f
to
1335dd4
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.
Great job @spaghetticode
@spaghetticode one thing that just came to mind: how about adding a test for the new event? |
@aldesantis sure 👍 |
The event is fired when the order recalculation process is completed, just before saving the order. This allows us also to deprecate the use of order's `update_hooks`.
This instance method is called in `Order#finalize!` and in `OrderUpdater#update`. Those methods now spawn the events `order_recalculated` and `order_finalized`, so when removing an existing hook, one must subscribe their hook code to both those events. Explicit calls to `OrderUpdater#run_hooks` can be replaced with `Spree::Event.fire :order_recalculated`.
As the method is deprecated, we should limit calling it to only when strictly necessary, ie when there's some actual hook to be executed.
1335dd4
to
c3a1283
Compare
@aldesantis test added. When you confirm it looks good to you I'll merge this PR. |
@spaghetticode looks good to me, feel free to merge! |
Please see PR #[3553](solidusio/solidus#3553) for more information concerning this change.
Please see PR #[3553](solidusio/solidus#3553) for more information concerning this change.
Please see PR #[3553](solidusio/solidus#3553) for more information concerning this change.
This PR adds the new event
order_recalculated
, also deprecating the use of order update hooks and the public methodOrderUpdater#run_hooks
. A conditional check has been added before running#run_hooks
in order to avoid tons of not-needed deprecation messages.Checklist: