• Resolved shivapentacove

    (@shivapentacove)


    I have a product that has 1 item in stock. I proceed to buy it and decide to pay via PayPal. I log out on the payment screen, leaving the order as Pending Payment.
    
    In the meantime, another customer purchases the item. The stock is now 0.
    
    I go back to my account page, reach the order payment link and choose to pay via Check instead. The order is successfully processed and the stock of the item is reduced to -1.
    
    Backorders are not allowed.
    
    To Reproduce
    Steps to reproduce the behavior:
    
    Set the stock of a product to 1
    Purchase it via PayPal but leave before paying.
    Reduce the stock to 0
    As customer, go to the order payment page and choose to pay via check
    The order is processed and stock reduced to -1

    I would like to reduce the stock as soon as an order is placed and the order is put in pending payment than wait till payment confirmation is recieved.

    I tried this code piece as well and it did not work.

    add_action( ‘init’, function() {
    add_action(‘woocommerce_order_status_pending’, ‘wc_maybe_reduce_stock_levels’);
    remove_action(‘woocommerce_order_status_pending’, ‘wc_maybe_increase_stock_levels’);
    });

    Anbody have a good solution?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How to reduce stock once order is placed and is on pending payment’ is closed to new replies.