First, thanks in advance for any insight.
I'm using the following in a simple extension to set the status for new orders with the aim that I can send an email template based on the customer's member group:
public function store_order_complete_end($order)
{
$status = Store\Model\Status::where('name', $status_name)->first();
if (ee()->session->userdata('group_id') == 10)
{
$status->name = "Commercial";
}
else
{
$status->name = "General";
}
$order->updateStatus($status);
return $order;
}
When processing an order, the system correctly sets the status to either Commercial or General. However, no email is sent. If I switch to another status and then back to the desired status, the email does send. In other words, it seems that the emails are only triggered when manually selecting the status.
Note that I have default order status of "Received" that does not trigger any email templates. I've done this because I've found that if no default status is set no email templates ever get sent -- even when manually selected.
Also, when looking at the bottom of the order detail, I do see that both order statuses are logged: Received and Commercial (or General).
Any thoughts?