Repository navigation
Push kit availability to Shopify - #9
Merged
Merged
Conversation
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.
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.
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()):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.stock_changed(stock or reservations) also queues every mapped kit that uses it.ProductComponentmodel events and queues the kit at once.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.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).