Skip to content

Push kit availability to Shopify - #9

Merged
mpge merged 2 commits into
mainfrom
feat/kit-availability
Nov 30, 2026
Merged

mpge merged 2 commits into
mainfrom
feat/kit-availability

Conversation

@mpge

@mpge mpge commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Why

Since Inventoros 2.7 (Inventoros/Inventoros#472), core sells a kit by taking its components and never moves the kit's own stock. So a kit mapped to a Shopify variant was pushed its stored stock (usually 0) and never updated when its components moved.

What

On cores that sell kits from components (KitStock::supported()):

  • Right number: a kit is pushed how many its components can make, from KitSaleService::available() (on hand less reservations, the number core sells against). It goes to the primary or "all stock" location only, because core counts kit availability across all warehouses.
  • Follows its components: a component's stock_changed (stock or reservations) also queues every mapped kit that uses it.
  • Component list edits: core fires no hook for these, so the plugin listens to ProductComponent model events and queues the kit at once.
  • Scheduled sync: shopify:sync (every 15 minutes) also pushes a mapped kit whose count differs from the last one sent. An unchanged count is not sent again: the first version of this PR did, which could put back on sale kits Shopify had sold in orders Inventoros had not imported yet.
  • Never pulled: when Shopify owns stock, its level for a kit isn't written back, because the kit keeps no stock of its own.

Orders needed no change. A Shopify order for a kit already imports through OrderService, which takes the components. If Inventoros can't fill it, the order goes to the dead letters with the short component named.

Older cores keep pushing a kit's own stock, as before.

Known limit (documented)

Two kits that share a component each show the full count that component allows. Shopify can sell more of them together than the shared part covers until the next push, and Inventoros then holds back the order it can't fill.

Tests

KitAvailabilityTest (10 tests) covers the component change pushing the kit count, reservations, an unrelated product not pushing, a component-list edit pushing at once, the scheduled push of a changed count and not of an unchanged one, an unsellable kit pushing 0, an order taking components, a short order held back naming the component, and pull skipping kits.

Full plugin suite inside an Inventoros checkout (core main): 172 passed (SQLite).

mpge added 2 commits November 24, 2026 14:48
Inventoros 2.7 sells a kit by taking its components and never moves the
kit's own stock, so a mapped kit was pushed a stale stored number and
never updated. On those cores (KitStock::supported()):

- a kit is pushed how many its components can make (KitSaleService,
  on hand less reservations) at the primary or "all stock" location;
- a component's stock_changed (stock or reservations) also queues every
  mapped kit that uses it;
- the scheduled sync re-pushes mapped kits, because editing a kit's
  component list fires no core hook;
- a Shopify level for a kit is never pulled into Inventoros.

Older cores push the kit's own stock as before. Orders for kits already
import through OrderService, which takes the components or refuses the
order naming the short component.
@mpge
mpge merged commit aad78ed into main Nov 30, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant