Skip to content

Instantly share code, notes, and snippets.

@charliesjc
Created August 7, 2021 15:32
Show Gist options
  • Save charliesjc/b3bfa1e2c35bd3c21f426c05b1db8234 to your computer and use it in GitHub Desktop.
Save charliesjc/b3bfa1e2c35bd3c21f426c05b1db8234 to your computer and use it in GitHub Desktop.
Change order status to on-hold immediately after payment
<?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