This content has been marked as final. Show 3 replies
Hi Grando,1 person found this helpful
In cartModifierFormHandler's add item to order method you can put a manual check using InventoryManager's queryStockLevel() method.
I hope, while checkout you must be getting exception when you don't have sufficient items available in your inventory, if not you can escape those issues by modifying cart modifier itself.
You can create a new pipeline chain for validating the inventory and call this chain in each step of checkout flow like while adding an item to cart, when navigating from cart page to shipping page, from shipping page to billing page etc. In this way you will make sure that the inventory is available throughout the checkout process.
The stockLevel may become 0 when user is in shipping page or in billing page. To take care of these scenarios validating inventory in each step is required.
I second with Avinash's answer above. In your commercepipeline, you can create processors to check for inventory at each step of the checkout flow - addItemToOrder, moveToPurchaseInfo, validateShippingGroup etc. If the inventory calls are expensive, then you can use a soft check like lastKnowLevel (or a Cache of some sort) during addItemToOrder and only do real inventory check at the final stage of the checkout process like moveToPurchaceInfo or processOrder.