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.
-
Right now it's possible - particularly when using an extension that alters the
order#finalize
method (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#finalize
method will not run. (Or if it breaks mid-way through finalize, only a portion of it will run).Since
completed_at
is only touched as a last step infinalize
, this means that it's possible for an order to be in thecomplete
state without acompleted_at
date.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
complete
scope, 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_at
as a step during completion instead of after, so there is no more discrepancy betweencomplete
andcompleted_at
(if an order fails to complete,completed_at
should also roll back to nil)complete
scope 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 ofcomplete
is not considered complete)Beta Was this translation helpful? Give feedback.
All reactions