Created
August 7, 2021 15:32
-
-
Save charliesjc/b3bfa1e2c35bd3c21f426c05b1db8234 to your computer and use it in GitHub Desktop.
Change order status to on-hold immediately after payment
This file contains hidden or 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
<?php | |
/* | |
* Change payment status straight to on-hold after successful payment | |
* | |
* By using this hook instead of 'woocommerce_thankyou' you intercept the order status change before emails are sent. | |
* By doing it this way the only email that will be sent to the customer is the one for an on-hold order. | |
*/ | |
add_filter('woocommerce_payment_complete_order_status', 'semper_woocommerce_payment_complete_order_status', 10, 2 ); | |
function semper_woocommerce_payment_complete_order_status( $order_status, $order_id ) { | |
if ( ! $order_id ) { | |
return; | |
} | |
if ($order_status == 'processing') { | |
$order_status = 'on-hold'; | |
} | |
return $order_status; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment