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:

woocommerce-custom-order-status

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.

  • Updated on:
  • Posted Under: Plugins
AJ Clarke
Post Author: AJ Clarke

Hey. My name is AJ and I am the boss around here. I own and operate WPExplorer. A website dedicated to everything I love about WordPress.

Disclosure
Got something to say? Join the discussion.
  1. 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.
    • AJ Clarke | WPExplorer says:
      AJ Clarke | WPExplorer
      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?
      Admin
      • 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!
  2. yes, that's correct
  3. after instaling it i couldn't find the option page, is there anything wrong ? I'm currently using WC 1.6
  4. I want to buy the theme Blocky but no email contact with you for doubts
  5. 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.
  6. Doug Smith says:
    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.
  7. sailingsmitty says:
    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.
    • AJ Clarke | WPExplorer says:
      AJ Clarke | WPExplorer
      The code only shows you how to create the custom statuses. Email integration would require further development.
      Admin
  8. Awesome plugin! Anyone know how to add custom order status icons?
    • AJ Clarke | WPExplorer says:
      AJ Clarke | WPExplorer
      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. I haven't tried it, but this plugin might help you out: http://codecanyon.net/item/post-type-column-editor/758157?ref=WPExplorer (not for the icons, but maybe for displaying the taxonomies?)
      Admin
      • 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 ?
  9. bloorchi says:
    Hi What if you want order statuses to have custom ordering. say to add "handed to delivery" status between "processing" and "completed".
  10. Keith Pickett (@KeithPickett) says:
    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!
    • AJ Clarke | WPExplorer says:
      AJ Clarke | WPExplorer
      Unfortunately I'm not sure, but I'm approving the comment incase someone else knows ;)
      Admin
  11. David Woodthorpe says:
    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.
  12. Hello, What is the filter for adding this custom status to the bulk action status list ? Thanks and regards
  13. 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?
  14. 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?
  15. jeff1026j says:
    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?
  16. Thanks for plugin and tutorial!
  17. 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
  18. 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.
  19. 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?
  20. Brian Hanrahan says:
    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?
    • AJ Clarke says:
      AJ Clarke
      I am updating the post right now. WooCommerce removed the Taxonomy so the code needs a bit of tweaking.
      Admin
  21. Wayne Hesler-Mondore says:
    I get an INVALID TAXONOMY
  22. 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.
  23. 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
    • AJ Clarke says:
      AJ Clarke
      Unfortunately they have removed the order statuses taxonomy in WooCommerce :(
      Admin
    • AJ is right - you'll have to create a plugin or add some code to your theme functions.php to get this working:
      /*
       * Add some custom order status
       */
      add_filter( 'wc_order_statuses','add_wc_order_statuses', 9,1 );
      
      function add_wc_order_statuses( $order_statuses ) {
      
      	$order_statuses['wc-approved'] = _x( 'Approved', 'Order status', 'woocommerce' );
      	return $order_statuses;
      
      }
      
      // register a custom order status it so we can see it in admin
      register_post_status( 'wc-approved', array(
                  'label'                     => 'Approved',
                  '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)', 'woocommerce' )
              ) );
      
  24. Thank you AJ and Jeff for your reply!
  25. i have the plugin installed and added the code to my functions.php but still get invalid taxonomy - any ideas?
  26. How can I list all orders with a specific status on a page?
  27. T.McDermaid says:
    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:
    • AJ Clarke says:
      AJ Clarke
      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.
      Admin
  28. 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?
  29. Hi.. This code is great!!!. However, it does not maintains the status when I upgrade it. How can I do to solve this ?
    • Kyla
      What do you mean by "upgrade it"? Are you referring to a recent WooCommerce update and the code isn't working for you anymore?
      Admin

Leave a Reply

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