Automatically complete an order if is paid with credit card or Paypal in Woocommerce


I was working on a subscription site and i had a real big problem. When i was creating an order on the site and pay with credit card or paypal i got the order status On Hold.

This is no good for me as i wanted to allow users to get their subscription right then without me completing the order.

I know for some users maybe this is not the best solution because of the problems that can cause with somebody abusing the system but as long as i got my money on paypal or credit card i wanted to get the users the best experience.

So for this i created a simple code that can complete all orders paid different that checks and bank orders for Woocommerce.

This code needs to be added on functions.php in the theme folder.

add_action( 'woocommerce_thankyou', 'auto_complete_paid_order_dexblog', 20, 1 ); //this actually makes the hook to thank you page
function auto_complete_paid_order_dexblog( $order_id ) {
    if ( ! $order_id )

    // Get an instance of the WC_Product object
    $ord = wc_get_order( $order_id );

    // Bank wire, Cash on delivery and Cheque payment methods -  no updates.
    if ( in_array( $ord->get_payment_method(), array( 'bacs', 'cod', 'cheque', '' ) ) ) {
    } else {
        // all orders are marked as paid that are different that the 3 payment methods from above
        $order->update_status( 'completed' );


Please enter your comment!
Please enter your name here