By default, clean WooCommerce installation will change order status to Processing after successful payment. This is very useful for physical orders. Thanks to this behavior, the customers know the shop staff is working on the order. As the customer sees that the order is paid and being processed, he knows the staff is preparing the shipment packing the products. You can extend this scenario for all orders by using woocommerce_payment_complete hook or a plugin. Learn how to change order status after payment to Completed.
💡 Small tip: You can avoid the woocommerce_payment_complete hook and go straight to installing the plugin.
Just leaving you a link to it:
Automatic Payment Status →Table of contents
- Default WooCommerce behavior for order status change
- Change WooCommerce order status to Completed after payment using a filter - woocommerce_payment_complete
- Automatic order status change with a plugin
- Use a woocommerce_order_status_completed filter to execute an action after completing WooCommerce order
Default WooCommerce behavior for order status change
The only exception is when the items in the cart are Downloadable. If so, the order status will always change to Completed after successful payment.
This is also very convenient. In most cases, the store staff does not need to take any extra actions when the customer buys downloadable products. So it is a good idea to automatically change the order status to Completed.
Change WooCommerce order status to Completed after payment using a filter - woocommerce_payment_complete
After the successful payment, the woocommerce_payment_complete hook is fired. So you can use it to programmatically change every order’s status to Completed after payment.
Please add this PHP snippet to your WordPress / WooCommerce site:
How to add this PHP code to your WooCommerce site?
You can simply edit functions.php file of your theme and add the filter containing woocommerce_payment_complete hook. But please beware that you will lose the changes if you update your theme to the latest version.
One of the recommended solutions is to use a custom plugin and insert the code inside the plugin file. Using the custom plugin for adding the code you can be sure that changes won’t be lost and you will have full control over the code and will be able to turn it on / off.
Automatically change WooCommerce order status to Completed after payment using a plugin
Automatic Payment Status WooCommerce $39
Automatically change WooCommerce order status when the conditions you specify are met. Specify conditional logic for product, product type, category, and payment gateway.
💾 Active Installations: 7000+ | 🔄 Last update: 2024-09-07
Automatic Payment Status is a small yet very powerful WooCommerce plugin. It allows you to automatically change order statuses to Completed once you receive the payment.
The settings allow choosing which orders justify automatic changes in the status:
- no changes - the plugin won’t interfere with standard WooCommerce behavior
- for orders with at least one virtual product - the plugin will check the contents of every order and change its status to Completed after payment only if there is at least one virtual product in the cart
- for orders with virtual products only - if there’s at least one physical item in the order, the standard WooCommerce behavior won’t be changed. If there are only virtual products, the order status will be changed to Completed after the payment.
- for all orders - all orders’ statuses will be changed to Completed after successful payment
Here's a quick video that will guide you through the plugin settings:
Use a woocommerce_order_status_completed filter to execute an action after completing WooCommerce order
The woocommerce_order_status_completed hook is fired after setting the order status to Completed. So it will work perfectly with the Automatic Payment Status plugin! Use this hook to execute some action after completing a WooCommerce order. You can use the example below:
As you see from the code, your customer user role will be changed to VIP Member once the order is completed:
Summary
Well, so from my WooCommerce guide, you have learned how to use both woocommerce_payment_complete and woocommerce_order_status_completed. I hope you can use my examples for creating your own automations in your shop.
Please remember that you can also use a quick and simple Automatic Payment Status plugin to change the order status to Completed after payment.
In this article, you've learned a few things about:
- woocommerce_payment_complete hook
- woocommerce_order_status_completed hook
- woocommerce change order status programmatically
If you have any further questions, leave a comment below or contact us.