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
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
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
This is a neat custom function that you can use in your WooCommerce customization. It can be helpful to know the list of orders placed by the current user ID, for example, if they are in their “My Account” page and you have a custom tab where you want to show e.g. only failed orders. Sooner or later this is something you’ll need. Enjoy!
Continue reading WooCommerce: Get Current User Orders By Status
The customer’s WooCommerce My Account Orders page displays all their orders, no matter the “status” (completed, processing, on-hold, pending, etc.).
It may happen that you, as a WooCommerce store manager, need to hide certain orders, for example the “on-hold” ones, or all orders with a custom order status.
Thankfully, this is very easy with a few lines of PHP. Enjoy!
Continue reading WooCommerce: Hide Specific Orders (e.g. On Hold) From My Account Orders Page
What does “completed” really mean in regard to WooCommerce orders? No one knows. Admins and customers included.
For physical products, usually that’s when the order is shipped (unless you add a custom order status in between “processing” and “completed“). For digital stores, that’s when the downloads are delivered.
Now, wouldn’t it be cool if we could rename this “completed” order status label to something else? This would make everyone’s life easier. Well, thankfully with a few lines of code this is definitely possible… enjoy!
Continue reading WooCommerce: Rename “Completed” 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
An order can be marked as “completed” only by the WooCommerce store manager – manually. In certain cases, this operation may be automatic i.e. for downloadable orders.
However, what if we want our customers to complete (confirm) their processing order instead? Well, this is quite easy: we display a “CONFIRM ORDER” button under My Account > Orders, and on click some code triggers the status change. Enjoy!
Continue reading WooCommerce: Let Customers Complete a Processing Order
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
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
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
The “woocommerce_thankyou” hook 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
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