-
-
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
Configurable order state machine and reduce the number of possible transitions #3542
Configurable order state machine and reduce the number of possible transitions #3542
Conversation
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 know it's still WIP, but I left some comments, thanks!
@mamhoff it would be awesome to get this in 2.11, which is the last release of the 2.x branch. The idea is to merge this in 2.11 and deprecate the old state machine module, then remove it completely in 3.0. |
I can try to move this forward, if @mamhoff agrees. |
Sure, go ahead! I'm really happy this is moving forward.
Andrea Longhi <[email protected]> schrieb am Fr., 29. Mai 2020,
16:40:
… I can try to move this forward, if @mamhoff <https://github.com/mamhoff>
agrees.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3542 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFLXKMHQWUAIXVWTQVK3UTRT7CMZANCNFSM4LDDAQFA>
.
|
Quick note here, to reflect discussion on the issue: When this is merged, we can close #1576 |
0f1ea10
to
90e6fcf
Compare
2ece35b
to
2e7c5db
Compare
Putting this on hold because @kennyadsl had some opinions about potentially deprecating and then removing |
I hope to be able to talk about this in our Core Team meeting this week. |
In 7c4f82c, all relevant state machines except for the order one have been extracted into modules. This performs the same exercise for the order state machine. A lot of this code is deeply interlinked with the rest of the system, so you'd have to take lots of care when replacing this; but it should be possible nonetheless. The new state machine is named Spree::Core::StateMachines::Order and includes the same code of the old one. The newly named state machine is active on new stores generated from scratch and in Solidus tests, but old stores will still use the old one, unless the preference `Spree::Config.use_legacy_order_state_machine` is explicitly set to `false`. When using the old named state machine a deprecation warning will be printed at boot time, as Solidus 3.0 will start using the new order state machine by default.
This removes many, many transitions from the Order state machine definitions included in Spree::Core::StateMachines::Order, allowing us to reason more clearly about what the system is supposed to be doing and when. This new state machine definition is not active yet on existing stores, but will become standard from Solidus 3.0. The legacy state machine definitions from Spree::Order::Checkout are left untouched, so old stores can continue to use them. A bunch of transitions have been removed, and now an order can transition to: * Canceled only when Complete; * Awaiting Return only when Complete; * Returned only when Complete or Awaiting Return.
41bf48b
to
98099f0
Compare
I explored the idea of adding a deprecation to the constant |
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.
👍 Thanks, Andrea!
In Solidus 2.11, it isn't possible to cancel an order that hasn't been completed anymore[1], which causes our failure dispatchers to fail when they call `order.cancel!`. To work around the issue, we're now only cancelling if the state machine allows us to (i.e., on Solidus <= 2.10 and in customized state machines). If the order cannot be cancelled, we skip the transition silently. [1]: solidusio/solidus#3542
In Solidus 2.11, it isn't possible to cancel an order that hasn't been completed anymore[1], which causes our failure dispatchers to fail when they call `order.cancel!`. To work around the issue, we're now only cancelling if the state machine allows us to (i.e., on Solidus <= 2.10 and in customized state machines). If the order cannot be cancelled, we skip the transition silently. [1]: solidusio/solidus#3542
In Solidus 2.11, it isn't possible to cancel an order that hasn't been completed anymore[1], which causes our failure dispatchers to fail when they call `order.cancel!`. To work around the issue, we're now only cancelling if the state machine allows us to (i.e., on Solidus <= 2.10 and in customized state machines). If the order cannot be cancelled, we skip the transition silently. [1]: solidusio/solidus#3542
This PR can be divided into two logical parts that are interdependent and
breaking each one in their way. These parts are described in detail later.
Make Order state machine configurable
In 7c4f82c, all relevant state machines except for the order one have
been extracted into modules. This performs the same exercise for the
order state machine. A lot of this code is deeply interlinked with the
rest of the system, so you'd have to take lots of care when replacing
this; but it should be possible nonetheless.
The new state machine is named
Spree::Core::StateMachines::Order
andincludes the same code of the old one.
The newly named state machine is active on new stores generated from
scratch and in Solidus tests, but old stores will still use the old one,
unless the preference
Spree::Config.use_legacy_order_state_machine
isexplicitly set to
false
.When using the old named state machine a deprecation warning will be
printed at boot time, as Solidus 3.0 will start using the new order state
machine by default.
Reduce the number of new order state machine transitions
This removes many, many transitions from the Order state machine definitions
included in
Spree::Core::StateMachines::Order
, allowing us to reason moreclearly about what the system is supposed to be doing and when.
This new state machine definition is not active yet on existing stores, but
will become standard from Solidus 3.0.
The legacy state machine definitions from
Spree::Order::Checkout
are leftuntouched, so old stores can continue to use them.
A bunch of transitions have been removed, and now an order can transition to:
This change was initially proposed with #3532 but for convenience it
has been included directly here as the original PR, being a breaking change, was
not mergeable in isolation without the premise of the first part of this PR. Please
consider taking a look at the original PR for the interesting discussion.
Checklist: