Developer forum

Forum » Development » Disable stock remove after checkout

Disable stock remove after checkout

Yung Yi Wang
Reply

Is it possible to skip/disable/catch the stock remove after checkout is done and complete?

I have a manual stock removal when I add a product to the cart and after checkout is done and complete it is removing the quantity from stock again:(


Replies

 
Nicolai Høeg Pedersen
Reply

Hi Yung

You cannot disable the stock level handling in DW - you can however subscribe to the Notifications.eCommerce.Stock.StatusChanged notification which is available when the stock level is changed by DW and revoke it from there...

 
Yung Yi Wang
Reply

I did this is in the CheckoutDoneOrderIsCompleteObserver and also worked:

 

private void CounterStockRemoval(Order order)
        {
            foreach (var orderLine in order.OrderLines)
            {
                orderLine.Product.Save();
            }
        }

 

When I do this, the stock is also staying the same amount.

 
Nicolai Høeg Pedersen
Reply

Perfect, thanks for sharing.

 

You must be logged in to post in the forum