I have a script that changes the status of orders based on our ERP system.
In addition to that, we need to add customer notes. I found the way to do it:
$order->add_order_note($note);
$order->save();
Unfortunately this won't work outside the order edit screen, I tried to run it from my custom plugin. (source)
If I do it via $order->update_status($status, $note);
it only updates the status.
Is there a way to add a note outside the edit screen? (Including e-mailing the customer)