Skip to content

Push kit availability to Shopify - #9

Open
mpge wants to merge 1 commit into
mainfrom
feat/kit-availability
Open

mpge wants to merge 1 commit 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 when a kit's component list changes, so shopify:sync (every 15 minutes) re-pushes mapped kits. Pushes are absolute, so re-pushing an unchanged kit is harmless.
  • 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 (8 tests) covers the component change pushing the kit count, reservations, an unrelated product not pushing, the scheduled re-push after a component-list edit, an unsellable kit pushing 0, an order taking components, a short order held back naming the component, and pull skipping kits. Disabling the kit quantity, the component fan-out or the pull guard makes these tests fail.

Full plugin suite inside an Inventoros checkout: 170 passed (SQLite).

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.
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