Only reduce the stock inventory on completed orders in WooCommerce

Only reduce the stock inventory on completed orders in WooCommerce on child sites.

Snippet Type

Execute on Child Sites

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' );
}

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.