Use the order updater when shipping shipments, or dealing with payments.#389
Merged
magnusvk merged 2 commits intosolidusio:masterfrom Sep 24, 2015
Merged
Use the order updater when shipping shipments, or dealing with payments.#389magnusvk merged 2 commits intosolidusio:masterfrom
magnusvk merged 2 commits intosolidusio:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
At the point of this being a one-liner, should we inline it above?
Contributor
|
👍 for using |
We don't need to do this ourselves. Additionally a user may define hooks, which are run by the order updater that wouldn't get triggered whenever shipments are shipped, which is something worth knowing about. We also don't necessarily know that updating the shipment state shouldn't update other states or parts of the order.
While we keep the intention of only updating the order when the order or payment is in a certain state, we shouldn't be doing this manually. The order updater exposes a method that's responsible for the total update of an order, a payment shouldn't know that shipments need to be updated when the payment is saved. Additionally, this bypasses the order updater hooks, which run as part of the update process, preventing users who rely on these hooks for information about when state changes may occur from using the hooks to accomplish that goal.
Contributor
|
Take that, 4d652a7! |
Contributor
|
👍 This is also about responsibility and knowledge. A payment should not know that it needs to update the shipment state and the shipment should not know how to update the order. Very happy with this change. |
Contributor
|
👍 |
Member
|
Agree with the sentiments above. Nice work Richard. |
magnusvk
added a commit
that referenced
this pull request
Sep 24, 2015
Use the order updater when shipping shipments, or dealing with payments.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Each commit describes the reasons for their respective changes.
At a high level, none of these objects should need to know how to update an order after performing their responsibilities. It is fair to say that they could know that the order should be updated, but the logic for doing so should be encapsulated in the order updater.
Every time we don't use the updater in situations were we should, our codebase becomes less cohesive. A problem that was recently discovered was how difficult it was to be notified when the order was updated to a new state, or set of states. The updater provides hooks for this, but they're not used as classes outside of the updater have been updating the order themselves.