WooCommerce

Create a Custom Stock Status

In this tutorial I am going to show you how you can create a custom stock status for your WooCommerce products. There are a bunch of plugins over there, which allow you to implement similar functionality in one way or another, but why to use a plugin when can do exactly the same with a couple of lines of code in your theme. But of course, it depends.

As an example here we will create a “Contact us” custom product stock status, which will be kind of similar to “Out of stock” – customers won’t be able to add a product to a cart, but there is going to be a link to a contact page instead of an “Add to cart” button.

This custom product stock status will work with both standard WooCommerce features (like product filters) and third party plugins (my Duplicate SKU stock sync plugin for example).

Check if a Product Has Variations

In this simple tutorial I’d like to show you easy ways to check whether a specific product has variations or not.

The first thing you need to understand here is that variations are also a custom post type product_variation and “variation posts” are always child in relation to “product posts”.

The second thing is that we have public (“Enabled” checkbox is checked) and private (“Enabled” checkbox is unchecked) variations:

Enabled (public) and private variations of WooCommerce products

The thing is that depending on whether your variation is public or private, you need to use different functions and class methods.

Product Sync Plugins for WooCommerce

Let me introduce you the plugins which allow to sync WooCommerce products between stores.

Click any of the above links to jump straight to the specific plugin. Both plugins work very similar.

Let’s take a quick look now.

WooCommerce Network Orders Dashboard Widget

Today I am going to talk about a very interesting widget in WooCommerce which is available to you only when you’re using WooCommerce within a WordPress Multisite network:

WooCommerce network orders dashboard widget

This widget appears in two places:

  • Network admin dashboard,
  • Admin dashboard of a main site of your multisite network (usually a site with ID = 1).

In order for this widget to appear, WooCommerce has to be either network activated or activated for the main site of your network.

Let’s take a look how this widget really works.

Create or Update WooCommerce Orders via REST API

Yes, I know, I already have plenty of tutorials on this topic on my blog, for example I’ve showed you how to do the same for products, customers and so on. And now it is time to do it for WooCommerce orders.

By the way, if you’re looking for a way how you to delete orders using REST API, check this out.

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.

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.