Skip to content

Handle different line item/inventory unit variants - #6691

Merged
jarednorman merged 1 commit into
solidusio:mainfrom
SuperGoodSoft:availability-validator-unit-variants
Oct 20, 2026
Merged

jarednorman merged 1 commit into
solidusio:mainfrom
SuperGoodSoft:availability-validator-unit-variants

Conversation

@jarednorman

Copy link
Copy Markdown
Member

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_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:

Checklist

Check out our PR guidelines for more details.

The following are mandatory for all PRs:

The following are not always needed:

  • 📖 I have updated the README to account for my changes.
  • 📑 I have documented new code with YARD.
  • 🛣️ I have opened a PR to update the guides.
  • ✅ I have added automated tests to cover my changes.
  • 📸 I have attached screenshots to demo visual changes.

@jarednorman
jarednorman requested a review from a team as a code owner October 15, 2026 19:50
@github-actions github-actions Bot added the changelog:solidus_core Changes to the solidus_core gem label Oct 15, 2026
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
jarednorman force-pushed the availability-validator-unit-variants branch from c0ddd8f to 7487b9a Compare October 16, 2026 03:10
@codecov

codecov Bot commented Oct 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.46%. Comparing base (78fb02b) to head (7487b9a).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jarednorman
jarednorman merged commit 1514f27 into solidusio:main Oct 20, 2026
43 checks passed
@jarednorman
jarednorman deleted the availability-validator-unit-variants branch October 20, 2026 00:55
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:solidus_core Changes to the solidus_core gem

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants