Orders

Custom or Sequential Order Numbers in WooCommerce

The first thing we need to understand when we talk about WooCommerce order numbers is that order numbers and order IDs are not the same but by default WooCommerce uses order IDs as order numbers 🙃

Order numbers in WooCommerce admin:

Order numbers in WooCommerce admin

Order IDs in the database:

Order IDs in WooCommerce database

So the ID is just a column in the database which we probably shouldn’t touch, but we can do whatever we want with order numbers using woocommerce_order_number filter hook. And yes, if see any plugin out there which allows to change WooCommerce order numbers in one or another way, most likely the plugin is just using the mentioned hook.

Multisite Order Sync for WooCommerce

Sync orders from different sub-stores of a WordPress multisite network to a single store. It also lets you manage all the network orders in a one place and sync the changes back to sub-stores.

How to Delete a WooCommerce Order Programmatically

In this tutorial I would actually show you how to really delete a WooCommerce order programmatically, I mean because when I tried to find info about it, I only found recommendations about using wp_delete_post() function (which we can’t use it since HPOS appeared) or woocommerce_delete_shop_order() function (there is no such function).

I needed it when I was developing a synced order deletion feature for my Multisite Order Sync plugin.

The long story short, let’s just dive straight into it.

How to Run Heavy Functions on Repeatable Action Hooks

Sometimes when you’re using some hooks, for example save_post, you may notice that functions connected to those hook may be fired twice, for example it happens when you’re using outdated metaboxes instead of Gutenberg plugin sidebars.

But there is no need to worry about save_post hook because it can be fixed pretty easily – depending whether you’re using the Block Editor or not, just create meta fields the appropriate way and it fixes everything… it is woocommerce_update_order hook I am worried about.

When you create or update a WooCommerce order, the woocommerce_update_order action hook is going to be fired multiple times and at least it may create performance issues.

Order Items

Welcome to a complete tutorial about WooCommerce order items. Here we are going to talk about how to work with order items in code and then I have a very interesting real life example for you.

Create Orders Programmatically

In this tutorial we are going to dive deep into creating an order on your WooCommerce store completely via code. I already have a similar tutorial on my blog where we created a product programmatically.

First things first, you should know a very simple thing – yeah, orders is a WordPress custom post type and no, we can not use wp_insert_post() to create them. We have to use a CRUD layer for that. If it says nothing to you, please be patient, we’re going to dive into it in just a little bit.

How to Create a Custom Order Filter in WooCommerce Admin

In this guide I am going to show you how you can easily create a custom order filter for the WooCommerce > Orders page, which will work great for both CPT-based and HPOS orders.

In order to keep this tutorial as simple as possible we’re going to create a filter just by a single custom field value. This is how it is going to look:

how to create an order filter by a custom field in WooCommerce admin