Hi,
1. That's better.
2. Yes.
3. You're raising a good point here. onAfterOrderUpdate is called each time an order is changed. So no only when an order's status changes to confirmed.
So you need to improve your check to something like that:
if(!empty($order->order_status) && $order->order_status == $confirmed && $order->old->order_status != $confirmed){
...
}
That way, you'll be sure the code inside will only run when the order's status is being changed, and only when it's changed from something which isn't confirmed to confirmed.
Also, you might want to add a check like this, especially if you plan on releasing this plugin to others or if you plan on using HikaMarket in the future:
if($order->old->order_type!='sale') return;
HikaMarket will create sub sales (one sub order for each vendor of an order) with a different order_type than "sale". And you likely want to ignore these sub sales with that extra check.