Create WooCommerce Custom Order Statuses For WordPress
WooCommerce is an awesome WordPress plugin to sell products online. And today I’d like to show you how to create plugin to allow you to create custom order statuses. By default WooCommerce provides these order statuses:
- cancelled
- completed
- failed
- on-hold
- pending
- processing
- refunded
But what if you want to add new statuses, or maybe modify existing ones? Below is an example showing you how easy it is to add a new order status to your WooCommerce orders.
Visually here is the final result:
Register New WooCommerce Order Status
Previously WooCommerce used a “shop_order_status” taxonomy so adding new order statuses was a bit tricky, however, now it’s easier then ever! Have a look at the code below for an example.
// Register New Order Statuses
function wpex_wc_register_post_statuses() {
register_post_status( 'wc-custom-order-status', array(
'label' => _x( 'Custom Order Status Name', 'WooCommerce Order status', 'text_domain' ),
'public' => true,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'label_count' => _n_noop( 'Approved (%s)', 'Approved (%s)', 'text_domain' )
) );
}
add_filter( 'init', 'wpex_wc_register_post_statuses' );
// Add New Order Statuses to WooCommerce
function wpex_wc_add_order_statuses( $order_statuses ) {
$order_statuses['wc-custom-order-status'] = _x( 'Custom Order Status Name', 'WooCommerce Order status', 'text_domain' );
return $order_statuses;
}
add_filter( 'wc_order_statuses', 'wpex_wc_add_order_statuses' );
If you want to add multiple new order statuses simply duplicate the register_post_status function inside the wpex_wc_register_post_statuses function as many times as you want making sure to alter the ID and the labels accordingly. Then add the new order status to the $order_statuses array in the wpex_wc_add_order_statuses function.
I believe the purpose of the “show_in_nav_menus” parameter is for making the taxonomy terms available in the “Appearance > Menus” screen, so that you can add links to term archives in a custom menu.
Yes, that is what “show_in_nav_menus” does…maybe it has something to do with the fact that the terms are being added directly to the WooCommerce filter?
Any idea how to get these custom order statuses into the WooCommerce » Orders Bulk Edit Dropdown? It really is the only thing holding this plugin back from being effective! Great plugin otherwise!
yes, that’s correct
after instaling it i couldn’t find the option page, is there anything wrong ?
I’m currently using WC 1.6
there’s no options
I want to buy the theme Blocky but no email contact with you for doubts
simple and clean plugins, works great! I used this together with Twilio SMS woocommerce plugins with simple hack to send automated sms based on new created order statuses.
I added a re-opened status a while back to mark orders that have issues we’re dealing with. It’s been very handy.
One thing to note is that since any new status gets stored as a term for the existing WooCommerce taxonomy, this plugin can be removed if you don’t need to make any more changes and the new status will remain.
Will this plugin give the option in the WooCommerce Email settings (or elsewhere) to send an automated email to a customer once the order status has been updated? Thanks.
The code only shows you how to create the custom statuses. Email integration would require further development.
Awesome plugin! Anyone know how to add custom order status icons?
It’s very easy to do Travis, you just have to create custom Columns – http://codex.wordpress.org/Plugin_API/Action_Reference/manage_$post_type_posts_custom_column – You would just display a different image depending on the status.
Thanks AJ. But that is way beyond my understanding haha.
Thanks for this post. I added custom fields. However I would like to change order status to custom order status via ajax icons. I mean the last column in admin order list page. There are only two icon (two to change status for processing/completed) and ‘view order’ icon. I would like to have more icon that via ajax change order status. Do you have any tips for me ?
Hi
What if you want order statuses to have custom ordering. say to add “handed to delivery” status between “processing” and “completed”.
Is there a way to set the default order status to “processing” automatically after the order is placed? I can’t seem to find that in settings. I want to disable it from automatically moving the order status to cancelled if at all possible.
Thanks!
Unfortunately I’m not sure, but I’m approving the comment incase someone else knows 😉
Thankyou for the very handy plugin – I am trying to develop a quote / invoice system for my business and have managed to customise the my account page and add payment links to unpaid invoices but cannot work out how to allow these to be paid (when clicking the “pay” link the checkout always shows the invoice as already paid) – do you know where I should be looking to edit this behaviour?
Thankyou for any help you can provide.
Hello,
What is the filter for adding this custom status to the bulk action status list ?
Thanks and regards
Running WooCommerce 2.0.20, not seeing the custom order status from the dropdown menu on the order edit.php screen.
I downloaded and ran the plugin directly, is there something I’m missing?
More along the same lines as emcyze has asked: how do I get the custom order status to show in the bulk edit list on the aforementioned “edit.php” for orders in the admin?
I also want to ask, can I get the custom order status to show in the bulk edit list on the aforementioned “edit.php” for orders in the admin?
Thanks for plugin and tutorial!
Hello,
is it possible to call two action hooks for the Order status. ?
I mean my plugin file contains actions for woocommerce_order_status_processing hook, that has some function. Now I have also included woocommerce_order_status_pending hook, that does the same function as processing hook .
Processing Hook works fine for all the orders carried using Card /master card etc , but not when a user does a transaction using PayPal. Where my paypal orders are by default set to Pending in the back-end.
My query is that can there be two order Hooks defined in a custom woocommerce plugin file ?? . Or there is something else that I may be missing here ??
Any suggestions would be of a great help.
Thanks
Remy, is it possible to allow the customer to cancel his/her order from their My Account page? I have been trying to figure out how to do it via custom order status, but no dice.
you guys are so great & nice! thanks for plugin.
one quick question: is there any way/plugin to send an automated email to a customer once the order status has been updated?
Hi, I just installed and get an error of “Invalid Taxonomy” when I click on the “order statuses” link, running Woocommerce 2.2.4. Any ideas?
I am updating the post right now. WooCommerce removed the Taxonomy so the code needs a bit of tweaking.
I get an INVALID TAXONOMY
Hi,
Nice Post, Thanks for your post. I have downloded your plugin and activated it but your plugin is not working for me.
When I click on the menu “Order Statuses” in the admin panel, it shows an error msg “Invalid taxonomy.
Please solve the issue asap.
Hi! I am in need of precisely this functionality, but when I installed the plugin and went to the menu, it says “invalid taxonomy” Do I need to mess with the code as explained above, or the plugin was supposed to give me a UI where I’d add the customer order status I wanted?
Thanks you for your help! M
Unfortunately they have removed the order statuses taxonomy in WooCommerce 🙁
AJ is right – you’ll have to create a plugin or add some code to your theme functions.php to get this working:
Awesome, thanks for sharing Jeff!!!
Thank you AJ and Jeff for your reply!
i have the plugin installed and added the code to my functions.php but still get invalid taxonomy – any ideas?
I recently revised this post. please have a look.
How can I list all orders with a specific status on a page?
AJ,
Can you look at my code and tell me what I am doing wrong? I have tried to add more than one “Order Status” references which isn’t working:
Could you please post your code on Gist and then show me the link? When submitted through the comment form the formatting gets all messed up so I can’t really read it clearly.
Great Post 🙂
I’ve successfully added a custom order statsus.
Any orders with this type are now missing off the sales reports, any idea on how hey can be added to the sales report?
Thanks in advance for your help?
Hi.. This code is great!!!. However, it does not maintains the status when I upgrade it. How can I do to solve this ?
What do you mean by “upgrade it”? Are you referring to a recent WooCommerce update and the code isn’t working for you anymore?
Had the same problem that the new status was not saving, it jumped back to last status it had.
Turns out hte newly registered order status had a name that was to long, the maximum is 20 charachters for the status. As you can see in this stack overflow answer.