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:
- Creating a custom function connected either to the
woocommerce_product_set_stockor to the
woocommerce_variation_set_stockaction hook if we talking about variations.
- Obtaining the connected products and to setting the same stock values for them.
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:
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?
WooCommerce API – Product Sync with Multiple Stores
First of all we have to decide what is actually a product synchronisation? Let’s consider two scenarios here.
- Update a product with the same SKU on other WooCommerce stores automatically when it was updated by an administrator on the “Main store”. Here you can decide whether you would like to update a specific product data or all product data. And it is what we are going to do in this tutorial with code or with a plugin.
- Update product stock status and quantity on other WooCommerce stores not only when this product was updated by an administrator but also when the product was purchased (and its quantity was descreased, obviously). We are going to talk a little bit about it in this tutorial as well, but I recommend you to take a look at my another plugin which is intended to help you with that.
Bulk Copy and Update Products between WooCommerce Stores
Just another tutorial by your requests guys.
In this one we are about to create a bulk action like on the screenshot below which allows to sync products between two (or multiple) WooCommerce stores.
Get Product Stock Quantity
In this tutorial I will not only show you how to get stock quantity in WooCommerce (of a product or a product variation by the way) but we will also display it on the shop page. Like this: