Using the Clover API to Sync WooCommerce Product Quantities
I finally decided to see if I could convert a certain Django Python script to a PHP script. This was a work project. It took a long time, but I was able to convert it, and I also improved it. The Django app used the WooCommerce API to sync product quantities in WooCommerce and Clover, but the WooCommerce API is super slow. It took twenty minutes to sync the quantities of two hundred products.
There are actually two parts to the sync. I had to create one PHP function to sync quantities from WooCommerce to Clover and from Clover to WooCommerce.
WooCommerce to Clover
Syncing the products from WC to Clover wasn’t too difficult. It was very time consuming, and it took a ton of troubleshooting, but I finally got it to work. The function instantly updated the quantity of the clover product when a product was purchased in WooCommerce.
Clover to WooCommerce
The sync from Clover to WooCommerce was a little bit less sophisticated. The function just overwrites the quantities of the WC products with the quantities of Clover products. This function basically did what the Django script did, but it did it a lot faster. It only took about five second to sync the product quantities. I tried to see if I could instantly sync a WC product when a Clover product was purchased, but I wasn’t able to. Thankfully, a very nice person responded to my post in the forums telling me how to set up the webhook for Clover. Now, I have to set up.
I learned something very interesting completing that project. I can spend a ton of time on a back end project, and the time absolutely whizzes by.