I want to assign different default order status based on product types. Is this possible?

What I need to achieve is to send different email notifications based on product types. Can this be configured or do I need to add logic to and customize the email templates?

1 Answer 1


Edit: I'm sorry! I missed Commerce 1 in the title! This answer only applies to Commerce 2.

Take a look at the defaultOrderStatus event!

The description is a bit misleading—it's actually used to do exactly what you've described: alter the "default" completed order status in situations where it might not be desirable.

From the docs:

use craft\commerce\Plugin as Commerce;
use craft\commerce\events\DefaultOrderStatusEvent;
use craft\commerce\services\OrderStatuses;
use yii\base\Event;

    function (DefaultOrderStatusEvent $e) {
        $myOverriddenOrderStatus = Commerce::getInstance()->getOrderStatuses()->getOrderStatusByHandle('myCustomStatusHandle');

        $lineItems = $e->order->getLineItems();

        foreach ($lineItems as $lineItem) {
            // Your logic for checking the ProductType would
            // replace this basic test:
            if ($lineItem->price > 500) {
                $e->orderStatus = $myOverriddenOrderStatus;

        // Whatever `$e->orderStatus` ends up being by the time we exit
        // this event listener will be used as the new `OrderStatus`.
  • That's too bad; is there a solution for Commerce 1? Do I have to create a plugin for this?
    – biko
    Commented Jun 7, 2019 at 1:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.