WooCommerce – Page 3

Speeding Up WooCommerce API

I’ve been working with WooCommerce REST API for quite a while now, well, I developed a couple of plugins – Simple WordPress Crossposting and Simple Inventory Sync and both of them are relying on WooCommerce REST API.

And when you develop something that is intended to be used not only on your test website with 5 products total but also on high load websites, when orders can contain more than 100 products and variations, of course you should always keep performance in mind.

In this tutorial I will share with you some simple simple yet effective tips and tricks.

Update Products and Variations Stock from CSV

In this tutorial I would like to share with you a ready to use example how you can sync WooCommerce products and variations inventory with a CSV file automatically.

Our CSV file is going to look like this:

sync WooCommerce product stock quantities with CSV files
Of course, if you’re going to use the file just to sync stock quantities, ID and Name columns better be removed.

To make this tutorial a little bit simpler we are going to put the file in the WordPress uploads folder, but for sure you can create a WooCommerce settings page where you can upload it.

Reduce Product Stock Quantities Conditionally

When you turn the option “Manage Stock” on for your WooCommerce products (or variations), then every time an order is made, stock quantity of the products from the order is going to be automatically decreased.

But sometimes you don’t need that, or just need it for specific order statuses or payment methods. In this tutorial I will show you how you can do that.

Multiple Products from the Same Stock

In this tutorial I will show you how you make both Stock Quantity and Stock Status to be automatically shared between different products on your WooCommerce store. But if you come to this tutorial looking for a product inventory synchronisation tool between different WooCommerce stores, then please take a look at my plugin.

Also I am going to show you an example with variations of the same product.

The whole idea is pretty simple and can be breaked down into two steps:

  1. Creating a custom function connected either to the woocommerce_product_set_stock or to the woocommerce_variation_set_stock action hook if we talking about variations.
  2. Obtaining the connected products and to setting the same stock values for them.

Easy peasy.

Updating Product Stock Programmatically

Since I’ve been working a lot lately with synchronising product stock quantities between multiple WooCommerce stores or within a WordPress Multisite network, I can share with you some interesting insights how it is working.

How to Create a Custom System Status Tool

Quite recently I was guess what – working on my Simple Inventory Sync plugin and I was needed some kind of functionality that allows to push the actual product stock quantity to all substores via WooCommerce REST API (and that’s why it should be doing it in the background).

And I think that to create a tool in WooCommerce > Status > Tools is the most seemless way to implement that functionality.

For me it is still doesn’t make any sense why plugin developers overload WordPress admin menu with tons of settings when you can use build-in UI for that. Well, this is another story.

Here is a status tool we are going to create in this tutorial:

Create a custom system status tool in WooCommerce

Settings Pages in WooCommerce

Just a couple days ago I was doing some updates for one of my plugins and I decided to move plugin settings from a regular WordPress options pages to WooCommerce > Settings.

Because why overload WordPress admin menu with links when the plugin is intented to sync product inventory between stores and it is crystal clear that its settings should be in WooCommerce > Settings > Products > Inventory tab. Don’t you think so?