Skip to content

Instantly share code, notes, and snippets.

@Deviant96
Created July 21, 2023 15:48
Show Gist options
  • Save Deviant96/cc11d6e78c74bb12ca5f5ae471968646 to your computer and use it in GitHub Desktop.
Save Deviant96/cc11d6e78c74bb12ca5f5ae471968646 to your computer and use it in GitHub Desktop.
Increase stock on failed and cancelled order for Woocommerce
add_action('woocommerce_order_status_changed', 'custom_increase_stock_on_failed_and_cancelled_order', 10, 4 );
function custom_increase_stock_on_failed_and_cancelled_order( $order_id, $old_status, $new_status, $order ){
if ( $new_status == 'cancelled' || $new_status == 'failed' ){
wc_maybe_increase_stock_levels( $order_id );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment