WooCommerce product quantity change code
-
Dear Community,
I have a WooCommerce store (call it WooStore1) with product stock.
Because I have another online-store (call it OtherStore2) which is custom-built non-WP/WooCommerce, I have stock there too for the same products.
Because the majority of the products have quantity of 1 and are gone once sold, I need to ensure that WooStore1 and OtherStore2 stock quantities are synchronised and maintain correct, so I don’t double sell.
My initial idea is that in OtherStore2, when I have any stock quantity change system runs a function which updates stock quantity in WooStore2 via MySQL DB, by updating relevant _stock meta_value in DB.
So, this is pretty simple to have OtherStore2 updating WooStore1 stock quantity.
What I am stuck with, is if Product is sold in WooStore1, I don’t know how to update the OtherStore2.
All products are Simple products, and no variations.
Is there a way to create a function or add a script to be run when stock quantity is changed in WooCommerce Product, or when order, sale, return, happens?
Anyone could give some ideas, or propose a solution would be much appreciated.
Many thanks
Dom
- The topic ‘WooCommerce product quantity change code’ is closed to new replies.