Remove adjustments from cart orders when promotion is discarded - #6557
Merged
mamhoff merged 2 commits intoAug 28, 2026
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6557 +/- ##
=======================================
Coverage 92.16% 92.16%
=======================================
Files 1037 1037
Lines 21210 21211 +1
=======================================
+ Hits 19549 19550 +1
Misses 1661 1661 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
mamhoff
force-pushed
the
fix-promotion-discard-adjustments
branch
2 times, most recently
from
August 27, 2026 11:04
350d97f to
06536ea
Compare
Benefits need access to their promotion even when it's discarded to properly handle cleanup and checks. This matches the pattern used in OrderPromotion and PromotionCode associations.
mamhoff
force-pushed
the
fix-promotion-discard-adjustments
branch
from
August 27, 2026 11:53
06536ea to
8c3c033
Compare
jarednorman
approved these changes
Aug 27, 2026
💔 Some backports could not be created
Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation and see the Github Action logs for details |
Contributor
Author
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation |
Contributor
Author
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation |
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
Fix orphaned adjustments from discarded promotions.
Problem
When a promotion is soft-deleted (discarded), it cleans up
order_promotionsassociations for incomplete orders but leaves behind the adjustments that were created by the promotion's benefits. These orphaned adjustments cause crashes during order recalculation because the code tries to accessadjustment.source.promotion.lane, but the promotion association returnsnilfor discarded promotions.Error example:
Solution
with_discardedscope to the benefit → promotion association so discarded promotions can be accessed (matches pattern inOrderPromotionandPromotionCode)remove_adjustments_from_incomplete_orderson each benefit to immediately clean up orphaned adjustmentsChanges
with_discardedtoBenefit#promotionassociationPromotion#delete_cart_connectionsto remove adjustments from incomplete orders when promotion is discardedChecklist