Couple completed_at touch with complete state on orders
#4482
Replies: 3 comments 4 replies
-
|
@seand7565 thanks for opening this discussion.
Using this solution, if an exception makes the order completion fail, wouldn't be the order considered completed even if it's not? Did you already evaluate moving the |
Beta Was this translation helpful? Give feedback.
-
|
At the moment, transactions for the order state machine are turned off. Maybe this is the root of the problem here? |
Beta Was this translation helpful? Give feedback.
-
|
Adding to the confusion we also have |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Right now it's possible - particularly when using an extension that alters the
order#finalizemethod (looking at you, solidus_subscriptions) - to have an order pass thecomplete!step, then fail in a completion after hook.Functionally, this means that the
order#finalizemethod will not run. (Or if it breaks mid-way through finalize, only a portion of it will run).Since
completed_atis only touched as a last step infinalize, this means that it's possible for an order to be in thecompletestate without acompleted_atdate.That's a problem by itself, but made worse because the orders complete scope only looks for orders that have a completed_at date.
This can lead to issues that go undiagnosed for some time. Since these orders are not in the
completescope, they won't show up on the admin orders panel, and if your error reporting didn't catch the initial error (or you didn't delve into it deep enough), you can wind up with paid orders that sit unshipped forever.Potential solutions:
completed_atas a step during completion instead of after, so there is no more discrepancy betweencompleteandcompleted_at(if an order fails to complete,completed_atshould also roll back to nil)completescope to look for orders with a state ofcomplete- I think that is a less surprising way to search for completed orders. (It's really hard to understand at a glance why an order with the state ofcompleteis not considered complete)Beta Was this translation helpful? Give feedback.
All reactions