I'm currently facing an issue in WooCommerce where the inventory stock count is being reduced immediately after a customer places an order. However, I would like to change this behavior and implement a system where the stock quantity remains unchanged until I manually confirm the order from the WooCommerce dashboard.
I would greatly appreciate it if someone could kindly provide me with a code snippet or guidance on how to achieve this functionality. I'm looking for a solution that allows me to confirm orders from the dashboard before the inventory stock count is reduced.
What you can do is allowing inventory stock count reduction only when an order status is set as "completed" by the Shop manager, using the following code snippet:
add_action( 'init', 'custom_wc_maybe_reduce_stock_levels', 10 );
function custom_wc_maybe_reduce_stock_levels(){
// remove_action( 'woocommerce_order_status_completed', 'wc_maybe_reduce_stock_levels' );
remove_action( 'woocommerce_payment_complete', 'wc_maybe_reduce_stock_levels' );
remove_action( 'woocommerce_order_status_processing', 'wc_maybe_reduce_stock_levels' );
remove_action( 'woocommerce_order_status_on-hold', 'wc_maybe_reduce_stock_levels' );
add_action( 'woocommerce_payment_complete', 'wc_maybe_increase_stock_levels' );
add_action( 'woocommerce_order_status_processing', 'wc_maybe_increase_stock_levels' );
add_action( 'woocommerce_order_status_on-hold', 'wc_maybe_increase_stock_levels' );
}
Code goes in functions.php file of your active child theme (or active theme). it should work.
Based on WooCommerce some core functions wc_maybe_reduce_stock_levels( $order_id )
and wc_maybe_increase_stock_levels( $order_id )
, that are involved in managing stock levels for order items within an order.