For version 2.x.x documentation please see here »
This tutorial will describe how to install and set up Stock Sync for WooCommerce. The tutorial applies to both Free and Pro versions.
There are four necessary steps which we will go through:
- Installing plugin
- Creating API keys for WooCommerce REST API
- Setting API credentials
- Initial synchronization of stock quantities
In addition there is troubleshooting section if you run into any issues. For example, stock discrepancies or failed syncing.
1. Installing plugin
First step is to install the plugin. It’s installed just like any other WordPress plugin.
- Download the plugin zip file
- Go to Plugins in the WordPress admin panel
- Click Add new and Upload plugin
- Choose the downloaded zip file and upload it
- Activate the plugin
1.1 Upgrading from Free to Pro
Upgrading from Free to Pro version is really simple:
- Activate Pro version
- Deactivate Free version
All settings will be preserved and Pro version works right away.
2. Creating API keys
Stock Sync for WooCommerce uses WooCommerce built-in REST API for communication between stores. First you will need to create API keys in all stores.
- Go to WooCommerce > Settings > Advanced > REST API > Add key
- Enter a description, select a WordPress user and set permissions to Read/Write
- WordPress user should have necessary permissions to edit product stock quantities, for example Administrator
- Take note of consumer key and secret
- Do steps 1 – 3 for all stores which share same stock
- Free version supports syncing between 2 stores, Pro version between 2 – 4 stores
3. Setting API credentials
Once you have created API credentials for both of the stores, you will need enter them in the settings.
- Go to WooCommerce > Settings > Stock Sync
- Enter the following settings under API Credentials
- URL – URL of the other store, for example https://store-a.com
- API Key – consumer key of the other store you created in the previous step
- API Secret – consumer secret of the other store you created in the previous step
- Click Check credentials to ensure they are correct
- This will create a test product to the other store via API and delete the product after that. This is required in order to check for read / write access. Other data is not affected.
- Do steps 1 – 3 for all stores
- Free version supports syncing between 2 stores, Pro version between 2 – 4 stores
4. Initial synchronization
Initial stock quantities should be imported from one store to the other(s). This way stock quantities will match between all stores before you start syncing. Import stock quantities from the store that has correct stock quantities.
- Go to WooCommerce > Stock Sync
- Select site and click Update sync status to see which product stock quantities will be imported. SKU is used to match products between stores.
- If some products are not syncing and they should sync, you will need to add matching SKUs
- Select site and click Import stock quantities once you have confirmed correct products are to be synced
All done! When you make changes to stock quantities via admin edit screen, refund a order or someone purchases a product, stock quantities will be synced between stores.
Troubleshooting
Stock Sync for WooCommerce writes log files about syncing. You can find out the following things by viewing logs:
- Possible errors in syncing process, for example invalid API credentials
- All successful sync jobs
- All failed sync jobs and error message
You can view log files by going to WooCommerce > Status > Logs and selecting woo-stock-sync-x-x-x-xxxxx.log. Each day will have own log file.
Troubleshooting: Syntax error
In some cases “Syntax error” will occur when trying to sync stock quantities or validating credentials in the settings. The reason why it happens is that the other website responds in a non-standard way that cannot be handled correctly. There are a few common reasons why it happens:
- URL is invalid / doesn’t respond – try to visit with your browser and ensure it displays the URL correctly
- Some security / firewall plugin causes the error, such as Defender – disable security plugins temporarily and test again
- Another plugin is causing a conflict which results in an error – check PHP and WordPress error / debug logs
- SSL certificate is invalid – try with valid SSL certificate or disable SSL temporarily
- HTTP basic authentication is enabled which prevents connection – disable any HTTP basic auth
- Multilingual plugin such as WPML or Polylang is redirecting from base path (https://example.com) to language path (https://example.com/en) – try to add language code (e.g. /en) to the URL
The plugin will log the URL, response code and body which sometimes can give hint about the issue. You can view the log in WooCommerce > Status > Logs > woo-stock-sync-exception-x-x-x-xxxxx.log. The log is different from the basic debugging log (woo-stock-sync-x-x-x-xxxxx.log). In the example below the reason is 404 error which means that the page couldn’t be found.