Repository navigation
Handle different line item/inventory unit variants - #6691
Merged
jarednorman merged 1 commit intoOct 20, 2026
Merged
jarednorman merged 1 commit into
jarednorman merged 1 commit into
Conversation
When a line item had inventory units, the validator counted pending units per stock location and checked line_item.variant against each count. This assumed every unit shared the line item's variant. This assumption doesn't hold when stores use solidus_product_assembly or implement their own bundling systems. It also doesn't hold even without such customizations: `ReturnItem#build_exchange_inventory_unit` attaches a unit with the exchange variant to the original line item. This means that an exchange on an order that gets canceled and resumed (admittedly not a common thing) would get validated against the original variant's stock, not the exchanged variant. Technically a bug. The `InventoryUnitsFinalizer` was fixed ages ago to unstock each unit's own variant. This change updates the validator to check stock the same way, against the inventory unit's variant. For ordinary stores, this doesn't change anything. For stores that implement bundling or use solidus_product_assembly, we can simplify things. Previously Product Assembly replaced this whole class; after this it'll only have to make one small modification. References: - Discussion solidusio#4489 - The finalizer was fixed in d3411e6 - https://jardo.dev/an-update-on-bundles-in-solidus
jarednorman
force-pushed
the
availability-validator-unit-variants
branch
from
October 16, 2026 03:10
c0ddd8f to
7487b9a
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6691 +/- ##
=======================================
Coverage 92.46% 92.46%
=======================================
Files 1057 1057
Lines 21465 21467 +2
=======================================
+ Hits 19848 19850 +2
Misses 1617 1617 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
AlistairNorman
approved these changes
Oct 17, 2026
adammathys
approved these changes
Oct 19, 2026
Noah-Silvera
pushed a commit
to SuperGoodSoft/solidus
that referenced
this pull request
Nov 2, 2026
…idator-unit-variants Handle different line item/inventory unit variants
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
When a line item had inventory units, the validator counted pending units per stock location and checked line_item.variant against each count. This assumed every unit shared the line item's variant.
This assumption doesn't hold when stores use solidus_product_assembly or implement their own bundling systems. It also doesn't hold even without such customizations:
ReturnItem#build_exchange_inventory_unitattaches a unit with the exchange variant to the original line item. This means that an exchange on an order that gets canceled and resumed (admittedly not a common thing) would get validated against the original variant's stock, not the exchanged variant. Technically a bug.The
InventoryUnitsFinalizerwas fixed ages ago to unstock each unit's own variant. This change updates the validator to check stock the same way, against the inventory unit's variant.For ordinary stores, this doesn't change anything. For stores that implement bundling or use solidus_product_assembly, we can simplify things. Previously Product Assembly replaced this whole class; after this it'll only have to make one small modification.
References:
Checklist
Check out our PR guidelines for more details.
The following are mandatory for all PRs:
The following are not always needed: