How to reduce stock of processing order in Woocommerce?

Work with stock in Woocommerce might be a pain in some cases. Do you need to reduce stock in processing status of order?

There is a plugin, Reduce stock of manual orders for WooCommerce, which reduces stock not only of manual, but also standard orders.

Don’t use this one! There is an issue, that it reduces stock not only of processing order, but also when it is completed.

It means, if there are 2 items in stock, and customer orders only 1, plugin would reduce stock to 0 and system shows product as “out of stock“.

Reduce stock on processing order

Add this piece of code into your functions.php:

function reduce_stock_processing($order_id) {
     wc_reduce_stock_levels($order_id);
}
add_action('woocommerce_order_status_processing', 'reduce_stock_processing');

When e.g. customer pays via PayPal, order has “Pending payment” status. When you switch it into “Processing“, stock reduces and you see the information on order detail.

If you use BACS (direct bank/wire transfer), new order shows usually “On hold” status. The stock has already decreased the product amount.

The stock doesn’t reduce again if you mark order as “Completed” in any case.

It works well also if using variations of products.