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: Save & Display Order Total Weight

For tracking purposes, or maybe because your shop manager needs to be aware of this, saving the total weight of each order and displaying it on the single order admin page is quite simple.

That’s right – WooCommerce does not save this value by default. You either need to save it yourself into the “order meta” or recalculate the weight based on the order items and their quantities. Here, we’ll cover option one (saving is better than calculating in regard to performance).

Enjoy 🙂

Continue reading WooCommerce: Save & Display Order Total Weight

WooCommerce: Set Checkout Field Value @ Order Creation

This is a very specific function. Sometimes, you need to “set” a checkout field value upon order creation (because it was not required and left empty for example). In some other cases, you might want to override what the customer input if you have certain requirements.

Either way, overriding the checkout fields on order creation is super easy. Here’s how it’s done – enjoy!

Continue reading WooCommerce: Set Checkout Field Value @ Order Creation

WooCommerce: Send Email to Admin Every 3 Hours (Cron Job)

This snippet consists of many WooCommerce tasks: setting up a “WordPress Cron Job” (i.e. schedule a hook that runs on a specific time interval), getting the WooCommerce completed orders from the database, and finally sending a simple email to the store admin.

Complex, but as usual you can simply copy/paste and re-adapt it to your unique specifications. For example, I’m using it to send a survey email to each customer who has placed an order. There are thousands of applications, so this is just the start. Enjoy! Continue reading WooCommerce: Send Email to Admin Every 3 Hours (Cron Job)

WooCommerce: Add Column to Orders Table @ WP Dashboard

The WooCommerce Orders Table, which can be found under WP Dashboard > WooCommerce > Orders, provides us with 7 default columns: Order Number – Date – Status – Bill To – Ship To – Total – Actions. This is used by shop managers to have an overview of all orders, before eventually clicking on a specific one.

So the question is: how can we display additional columns to that same orders table, so that we can immediately visualize an order custom field, a specific product contained in the order, or anything order-related that can be “calculated” once we have access to the $order variable?

Continue reading WooCommerce: Add Column to Orders Table @ WP Dashboard

WooCommerce: How to Add 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: How to Add a Custom Order Status

WooCommerce: Don’t Send Emails for Free Orders

There are times when you sell free products to give customers access to a membership, an online course, or for other reasons. In these cases, you might not want to send the “Order Completed” email or get the “New Order” transactional notification, so that you can avoid sending and receiving hundreds of emails.

Of course, you’d still want to keep the order emails for amounts above $0. Here’s the fix.

Continue reading WooCommerce: Don’t Send Emails for Free Orders

WooCommerce: Get Order Data (total, items, etc) From $order Object

As a WooCommerce development freelancer, every day I repeat many coding operations that make me waste time. One of them is: “How to get ____ if I have the $order variable/object?“.

For example, “How can I get the order total“? Or “How can I get the order items“? Or maybe the order dates, customer ID, billing info, payment method, order status, and so on… hopefully this article will help you save time as well!

As we’ve seen in other articles, get product info from $product object and get cart info from $cart object, not always you can have direct access to the $order variable.

Sometimes, you may have the $order_id available for example. In that scenario, you can “get” the order object with the wc_get_order WooCommerce function.

It’s also possible to gain $order information if you are in an email template. This can be helpful to show additional $order information in your transactional communications or trigger custom functions. Either way, enjoy!

Continue reading WooCommerce: Get Order Data (total, items, etc) From $order Object

WooCommerce: Check if Product Category is in the Order

We already saw how to check if a product category is in the cart, if a product ID is in the cart, and if a product ID is in the order… now it’s time to complete the series with the latest addition!

For this client, the scope was to do something on the “Thank You” page if a certain product category was purchased. For example, echo a “Thank you for becoming a member!” image in case the category “membership” was in the order.

Here’s the snippet, together with PHP comments so that you can understand how this is done. Enjoy!

Continue reading WooCommerce: Check if Product Category is in the Order

WooCommerce: Add Order Notes to WooCommerce PDF Invoices

I use the “WooCommerce PDF Invoices & Packing Slips” plugin, available on the WP Repository, to invoice my clients. At times, for accounting purposes, I need to show the VAT/TAX ID of the client on the PDF invoice.

So, I open the order via WooCommerce > Orders, open the order I want to edit, add a “Note to the Customer” from the right hand side… and then have the following snippet in my functions.php adding such information on the PDF invoice! Continue reading WooCommerce: Add Order Notes to WooCommerce PDF Invoices