Fix shipment adjustments not persisting on order recalculate#6334
Merged
tvdeyen merged 1 commit intosolidusio:mainfrom Oct 21, 2025
Merged
Conversation
75effa5 to
f05775e
Compare
benjaminwil
approved these changes
Oct 17, 2025
Contributor
benjaminwil
left a comment
There was a problem hiding this comment.
Thanks for finding this!
I think it would make sense to release this in a 4.6.1 patch. 💯
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6334 +/- ##
=======================================
Coverage 89.35% 89.35%
=======================================
Files 961 961
Lines 20195 20195
=======================================
Hits 18046 18046
Misses 2149 2149 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
A commit was made in solidusio#6315 (5979f25) in service of the in memory order updater solidusio#5872 that changed the behavior in the OrderTaxation class to set the adjustment value but not persist it. Instead, the persistence happens when the order is saved. If a shipment is changed, and an associated adjustment is changed, the shipment adjustment will be autosaved when the order is. However, if a shipment is *not* changed, but the adjustment is, the adjustment will *not* be autosaved when the order is. In solidusio#6315, we ensured that these changed associations cannot get left behind by setting `autosave: true`, which forces the model to check if it has any associations that need saving instead of telling it's relation "nope I haven't changed" We can do the same thing here for the shipment to ensure changing adjustments will make the shipment tell it's order "I have changed", even if none of it's direct properties have changed. You can test this change by removing the `autosave: true` option the adjustments and running 'when the address has changed to a different state' specs. They fail with the error "expected `order.shipments.first.adjustments.first.amount` to have changed from 1 to 2, but did not change", demonstrating a scenario where the shipment adjustment changes do not get persisted.
f05775e to
b47e0f0
Compare
Contributor
Author
I thought so too! |
adammathys
approved these changes
Oct 17, 2025
jarednorman
approved these changes
Oct 20, 2025
tvdeyen
approved these changes
Oct 21, 2025
Member
tvdeyen
left a comment
There was a problem hiding this comment.
Great commit message. This is how it's supposed to be done 👏🏻
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation and see the Github Action logs for details |
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.
Summary
A commit was made in #6315 (5979f25) in service of the in memory order updater #5872 that changed the behavior in the OrderTaxation class to set the adjustment value but not persist it. Instead, the persistence happens when the order is saved. If a shipment is changed, and an associated adjustment is changed, the shipment adjustment will be autosaved when the order is.
However, if a shipment is not changed, but the adjustment is, the adjustment will not be autosaved when the order is.
In #6315, we ensured that these changed associations cannot get left behind by setting
autosave: true, which forces the model to check if it has any associations that need saving instead of telling it's relation "nope I haven't changed"We can do the same thing here for the shipment to ensure changing adjustments will make the shipment tell it's order "I have changed", even if none of it's direct properties have changed.
You can test this change by removing the
autosave: trueoption the adjustments and running 'when the address has changed to a different state' specs. They fail with the error "expectedorder.shipments.first.adjustments.first.amountto have changed from 1 to 2, but did not change", demonstrating a scenario where the shipment adjustment changes do not get persisted.Checklist
Check out our PR guidelines for more details.
The following are mandatory for all PRs:
The following are not always needed: