Hi,
If you want to change the stock, I would recommend to do it either when the order is created or when the order status is updated to "confirmed" (it depends on your requirements)
For the order created, you can add your code in a trigger onAfterOrderCreate. The $order in it will contain all the data of the order and you can do a var_dump of the variable if you want to see what's inside and how to access what you need.
For the order status changed to confirmed, you want to add your code in a trigger onAfterOrderUpdate. You'll have to make sure that the status is being updated:
if($order->order_status=="confirmed" && $order->old->order_status=="created"){
//your code
}
The $order object might not always contain all the data of the order. So in your code, you'll want to load the data of the order as shown with one of the code sample we provide at the end of the developer documentation:
If you want to load the whole information of an order, you can use the code :
$orderClass = hikashop_get('class.order');
$order = $orderClass->loadFullOrder($order_id, true, false);