Home » WooCommerce: Change Payment Gateway Order Status

WooCommerce: Change Payment Gateway Order Status

by Tutor Aspire

Ok, we all know that Stripe, PayPal and all successful online payment orders go to “processing” order status, BACS and cheque go to “on-hold”, and so on. Each payment gateway has its own default paid status.

Now, what if you use custom order statuses, or what if you wish to change Stripe orders to “completed”, BACS orders to “pending” and PayPal orders to “on-hold”? Thankfully, this is super easy with a handy PHP snippet. Enjoy!

Each payment gateway comes with its own default paid order status. For example, BACS, COD and CHEQUE go to “on-hold” upon checkout. In this post, we’ll see how we can change that status to something else, either default or custom.

Before coding…

To make this customization, you will need to know a couple of things.

First of all, each payment gateway, whether it’s included in WooCommerce core or not, should provide you with a handy filter hook called “woocommerce_GATEWAYID_process_payment_order_status“, where GATEWAYID needs to be changed to the payment gateway ID. For example, this is the code for bank transfer gateway:

if ( $order->get_total() > 0 ) {
// Mark as on-hold (we're awaiting the payment).
$order->update_status( apply_filters( 'woocommerce_bacs_process_payment_order_status', 'on-hold', $order ), __( 'Awaiting BACS payment', 'woocommerce' ) );
}

Speaking of which, you will need to know the payment gateway ID, which you can do so with this other tutorial – in this way you’ll target exactly that payment method and not the others.

PHP Snippet 1: Change Default Paid Order Status for BACS Payment Gateway

/**
 * @snippet       BACS Order Status 
 * @how-to        Get tutoraspire.com FREE
 * @author        Tutor Aspire
 * @compatible    WooCommerce 6
 * @donate $9     https://www.tutoraspire.com
 */

add_filter( 'woocommerce_bacs_process_payment_order_status', 'tutoraspire_change_bacs_order_status', 9999, 2 );

function tutoraspire_change_bacs_order_status( $status, $order ) {
    return 'pending';
}

PHP Snippet 2: Change Default Paid Order Status for CHEQUE Payment Gateway

/**
 * @snippet       CHEQUE Order Status 
 * @how-to        Get tutoraspire.com FREE
 * @author        Tutor Aspire
 * @compatible    WooCommerce 6
 * @donate $9     https://www.tutoraspire.com
 */

add_filter( 'woocommerce_cheque_process_payment_order_status', 'tutoraspire_change_cheque_order_status', 9999, 2 );

function tutoraspire_change_cheque_order_status( $status, $order ) {
    return 'processing';
}

PHP Snippet 3: Change Default Paid Order Status for STRIPE Payment Gateway

/**
 * @snippet       STRIPE Order Status 
 * @how-to        Get tutoraspire.com FREE
 * @author        Tutor Aspire
 * @compatible    WooCommerce 6
 * @donate $9     https://www.tutoraspire.com
 */

add_filter( 'woocommerce_stripe_process_payment_order_status', 'tutoraspire_change_stripe_order_status', 9999, 2 );

function tutoraspire_change_stripe_order_status( $status, $order ) {
    return 'custom';
}

You may also like