How to add custom order statuses?

Hi everyone! I’m trying to modify my WooCommerce order status and I want to add two new ones: In Fulfillment and Payment on Product Pick-up.

WooCommerce: Allow Order Editing For Custom Order Status

WooCommerce admins are allowed to “edit” an order only when this is in the “on hold” or “pending payment” status. By “edit” I mean having the chance of modifying or adding products, fees, shipping and recalculating the totals, which are not allowed once the order has been placed (“processing“, “completed“, etc.).

However, there are many reasons why you’d want to have the right to edit a processing, completed, or custom status order – of course as long as you don’t end up changing the total, as customers already paid at that stage.

Think about the following scenarios:

  • you customized the items table and added a custom field, and you want to set the custom field value when the order is “processing
  • you need to edit the shipping method name AFTER checkout, and you want to be able to rename it when the order is “completed
  • you need to add a fee and a discount of equal amounts (so that the total stays the same) before completing the order

Either way, let’s enable the little “pencil icon” on a custom order status, so that the admin can customize the order whenever they wish!

Continue reading WooCommerce: Allow Order Editing For Custom Order Status

WooCommerce: Disable Restocking @ Order Cancelled

When an order that has previously reduced stock is “cancelled” or goes to “pending payment” because the payment failed or the store admin decided to change the order status, the wc_maybe_increase_stock_levels() function triggers and restores the order items’ stock quantity.

As usual, some WooCommerce entrepreneurs asked for a way to disable this automatic restocking given their custom setup. It often goes like that – you can’t really please everyone.

This is unless you’re a smart developer and can account for both options, thanks to a WordPress “filter“. Here’s a PHP one-liner that can immediately disable this default behavior, so that you can avoid the automatic restocking (and maybe doing it manually based on your business rules). Enjoy!

Continue reading WooCommerce: Disable Restocking @ Order Cancelled

WooCommerce: Resend Any Order Email

How annoying is the fact you can only resend the “New Order Notification” from the single order admin page? What if you’re testing out and customizing email templates, and need to email yourself the “processing” or the “completed” notification, without having to place a new test order or switching order status twice to re-trigger the notification?

Well, today we will see how to add a “Resend whatever email” function under the “order actions” on the single order edit page. Of course, make sure you switch the billing email to yours, otherwise the customer will get these emails and not you. Enjoy!

Continue reading WooCommerce: Resend Any Order Email

WooCommerce: Automatically Cancel Orders

You may wondering – “but I can already do that from the WooCommerce settings!“. Yes, that’s correct; go to WooCommerce Settings > Products > Inventory and set the “Hold Stock Minutes” value. After that period, unpaid orders will be marked as cancelled to make sure the stock goes back to the initial value.

The problem is – what if you don’t want to use the “Hold Stock Minutes” thing, and even better, what if you don’t use stock management at all? In that case, orders won’t be marked as cancelled automatically.

Also, what if you need to do conditional work e.g. you only want to cancel “failed” orders, while you want to keep “pending” ones as they are? Even in this case, the “hold stock” option won’t work, as you need to specify which order status you want to target and then run the cancel function.

Either way, enjoy!

Continue reading WooCommerce: Automatically Cancel Orders

WooCommerce: Change Payment Gateway Order Status

Ok, we all know that Stripe, PayPal and all successful online payment orders go to “processing” order status, BACS and cheque go to “on-hold”, and so on. Each payment gateway has its own default paid status.

Now, what if you use custom order statuses, or what if you wish to change Stripe orders to “completed”, BACS orders to “pending” and PayPal orders to “on-hold”? Thankfully, this is super easy with a handy PHP snippet. Enjoy!

Continue reading WooCommerce: Change Payment Gateway Order Status

WooCommerce: Advanced Order Search

When it comes to saving time, the out-of-the-box WooCommerce plugin doesn’t give you many options and features. For example, searching through your WooCommerce orders is not straight forward enough because the search options are fairly limited.

By default, you can go to the WooCommerce Orders admin page (wp-admin/edit.php?post_type=shop_order) and use the basic search bar.

You can look for a customer name, a customer billing email and a few more, but that’s pretty much all you can do. You can’t look for multiple fields, you can sort, you can’t filter by order total, and so on.

You get the picture – for a store manager this Orders dashboard is not handy at all. Each extra minute wasted in trying to find something could be better invested – in marketing spend for example.

That’s why we want to show you a quick alternative in order to do advanced searches in seconds. You won’t need any PHP snippets – just a quick plugin that turns your order list into an intuitive and easy-to-use spreadsheet so that you can do all the filtering and manipulation you desire.

Continue reading WooCommerce: Advanced Order Search

WooCommerce: Automatically Complete Processing Orders

If you wish to mark paid orders as “Completed” automatically (i.e. without having to manually login to the site and “check” processing orders one by one), you can use the code below.

What is more, this snippet will completely skip the “Processing” order status transition, which means no “Order Processing” email notification will trigger either. Once again, these 4 lines of code could save you millions of hours… hope this helps!

Continue reading WooCommerce: Automatically Complete Processing Orders

WooCommerce: Send a Custom Email on Order Status Change

If you use custom WooCommerce order statuses, or wish to target an order status transition that is not default (e.g. when order goes from “Processing” to “Completed”, the Completed email triggers – but what if you want to target a transition from “Processing” to “Custom Status”?), sending custom emails is quite complex.

First of all, they won’t show under WooCommerce > Settings > Emails (unless you code it, true) – second, no email will trigger. So, how do they do it?

Continue reading WooCommerce: Send a Custom Email on Order Status Change

WooCommerce: Disable Tracking if Order Failed @ Thank You Page

The “woocommerce_thankyouhook fires on the Thank You page once an order is placed. Most tracking functions like Google Analytics, affiliate commission plugins and other WooCommerce extensions rely on “woocommerce_thankyou” to run their code.

Problem is – “woocommerce_thankyou” is ALSO called if an order fails (i.e. payment did not go through). Now, unless the plugin is smart enough in its own functions to exclude failed orders, which doesn’t happen often I’m afraid, we need to find a way NOT to run “woocommerce_thankyou” if an order fails. Case study: a client uses a third party affiliate plugin, this plugin hooks into “woocommerce_thankyou“, but they don’t want to calculate conversions when an order fails.

So here you go!

Continue reading WooCommerce: Disable Tracking if Order Failed @ Thank You Page

WooCommerce: Create a Custom Order Status

All WooCommerce orders go to either “processing”, “completed”, “on-hold” and other default order statuses based on the payment method and product type.

Sometimes these statuses are not enough. For example, you might need to mark certain orders in a different way for tracking, filtering, exporting purposes. Or you might want to disable default emails by bypassing the default order status changes.

Either way, creating a custom order status is quite easy. And today we’ll see which PHP snippet you need in order to make this work!

Continue reading WooCommerce: Create a Custom Order Status