Created
May 24, 2023 19:39
-
-
Save lukecav/f9f9e5150eeb659846ae8b5fd5480235 to your computer and use it in GitHub Desktop.
Only reduce stock inventory on completed orders in WooCommerce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://stackoverflow.com/questions/76321233/allowing-inventory-stock-count-reduction-only-for-completed-orders-in-woocommerc/76321869