How to Automatically mark WooCommerce orders “Complete” on receipt of payment

Ever wanted your WooCommerce orders to be marked as “complete” straight away – for example if you never need them to be marked “processing” (maybe they are downloads, or a membership, or some other reason which means “processing” is not helpful to you, for example!?)?

The snippet below in this page will get you there. Its designed to make sure a WooCommerce order goes straight to Complete on the customer reaching the thank-you page – i.e. when their payment has successfully completed in WooCommerce.

Remember you can disable processing mail, too

Please note, it is still worth visiting WooCommerce > Settings > Emails and disabling the “Processing” email, as this may still be triggered, resulting in a double mail. If you’re not using the “processing” status, then turning off the mail is a good idea, as you simply don’t need it ever to fire.

The code snippet

The code snippet below should be placed into your child theme’s functions.php file, placed into a snippets plugin, or a custom plugin:

// Automatically complete woocommerce orders on successful payment (skip "processing") - Robin Scott for SiliconDales.com
add_action( 'woocommerce_thankyou', 'sd_woocommerce_auto_complete_order' );
function sd_woocommerce_auto_complete_order( $order_id ) {
if ( ! $order_id ) {
return;
}
$order = wc_get_order( $order_id );
$order->update_status( 'completed' );
}
view raw functions.php hosted with ❤ by GitHub

Let us know if this works for you!

Leave a comment below if this worked for you – or if you encountered any issues making this work – and help the Open Source community to learn from each other’s experiences, too.

4 thoughts on “How to Automatically mark WooCommerce orders “Complete” on receipt of payment

  1. Is there a way of doing this except for BACS paid orders, so for example PayPal and Stripe orders go straight to Completed but not BACS?

    1. Hi Jay – yes, it would be possible to do this selectively based on payment gateway. Its probably best to ask a developer to make a custom function based on this. You can find great WordPress and WooCommerce developers on Codeable (we have a form here which would allow you to post a task there: https://silicondales.com/post-a-task-to-codeable/ ) – if you use this form, you could link to this post URL (https://silicondales.com/tutorials/woocommerce/automatically-mark-woocommerce-orders-complete-receipt-payment/ ) and say “I’d like to use this function, but only if payment gateway other than bank transfer is used” – a developer will know how to build you this.

  2. Hello Robin,

    There is an issue with the idea.
    Some payment gateways use woocommerce_thankyou hook to throw up “Payment Failed” messages.
    Thus, there is a risk of orders being marked as “Completed” even when the payment has failed. This has happened to some of the orders on my store.
    Do you have a solution to the issue?

    Thanks,
    Manju

    1. Hi Manju,

      The short answer is, that is not where plugins should be loading “payment failed” messages- so try not to use gateways which do this, or write a new gateway plugin which uses the payment API correctly (throw an error and return “null”)

      https://docs.woocommerce.com/document/payment-gateway-api/

      What you are describing is “doing it wrong” – there’s no getting around that.

Leave a Reply

Your email address will not be published. Required fields are marked *