mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-29 11:32:21 +08:00
https://stackoverflow.com/questions/76321233/allowing-inventory-stock-count-reduction-only-for-completed-orders-in-woocommerc/76321869
12 lines
744 B
Text
12 lines
744 B
Text
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' );
|
|
}
|