Use WooCommerce function in other WordPress plugin

If you’ve already invoked the product, e.g. with

$product = new WC_Product($id);

then you can update the stock level with

$product->set_stock($stock);

For more information check the documentation:

https://docs.woothemes.com/wc-apidocs/class-WC_Product.html#_set_stock