Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Vineeth 71 posts 291 karma points
    Apr 08, 2019 @ 12:48

    Update stock value when order status changed to cancelled

    Is tea commerce inbuilt functionality updates stock value when a finalized order status is changed to cancelled from tea commerce backend?

    I need to update back the order line quantity to current stock value when a order status is changed to cancelled.

    If not how can we update the stock value?

  • Matt Brailsford 4099 posts 22021 karma points MVP 9x c-trib
    Apr 08, 2019 @ 13:43
    Matt Brailsford

    Hi Vineeth,

    No, Tea Commerce won't replenish stock values when an order is marked as canceled. If you wanted to achieve this, you'd need to hook into the events system, either the NotificationCenter.Order.PaymentStateChanged event to listen for a canceled payment or a NotificationCenter.Order.OrderStatusChanged to listen for an order being moved to the Canceled order status. From there, you'd need to check the order for the stock amounts to replenish and then call the product service to increase the stock levels for each item:

    decimal? stock = ProductService.Instance.GetStock(StoreId, sku);
    if (stock != null)
        ProductService.Instance.SetStock(StoreId, sku, stock.Value + quantity);

    Hope this helps


Please Sign in or register to post replies

Write your reply to: