3 Replies Latest reply: Jun 28, 2012 2:03 PM by 916602 RSS

    Problem with inventory stock when add item to order

    Grando
      Hi all,

      I am having a problem with my store: I have a product that has value 2 for stockLevel property in inventory.
      When I add this product to cart and update the quantity to 3, so in theory I couldn't buy it, because I just have 2 in my stockLevel.

      But this is the problem: I could buy 3 of the product, even though having 2 in stockLevel.
      I think that ATG still have a way to verify the quantity of stockLevel, to show errors or warnings when I try to buy more than I have in stock.

      Does anyone know how can I do this?

      Thanks for help
        • 1. Re: Problem with inventory stock when add item to order
          Prakhar
          Hi Grando,
          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.

          --
          Prakhar
          • 2. Re: Problem with inventory stock when add item to order
            Avinash Dathathri
            Grando,
            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.
            • 3. Re: Problem with inventory stock when add item to order
              916602
              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.