<blockquote>
  <p>Edit: I'm sorry! I missed <strong>Commerce 1</strong> in the title! This answer only applies to Commerce 2.</p>
</blockquote>

<p>Take a look at the <a href="https://docs.craftcms.com/commerce/v2/events.html#the-defaultorderstatus-event" rel="nofollow noreferrer"><code>defaultOrderStatus</code></a> event!</p>

<p>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.</p>

<p>From the docs:</p>

<pre class="lang-php prettyprint-override"><code>use craft\commerce\Plugin as Commerce;
use craft\commerce\events\DefaultOrderStatusEvent;
use craft\commerce\services\OrderStatuses;
use yii\base\Event;

Event::on(
    OrderStatuses::class,
    OrderStatuses::EVENT_DEFAULT_ORDER_STATUS,
    function (DefaultOrderStatusEvent $e) {
        $myOverriddenOrderStatus = Commerce::getInstance()-&gt;getOrderStatuses()-&gt;getOrderStatusByHandle('myCustomStatusHandle');

        $lineItems = $e-&gt;order-&gt;getLineItems();

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

        // Whatever `$e-&gt;orderStatus` ends up being by the time we exit
        // this event listener will be used as the new `OrderStatus`.
    });
</code></pre>

CC BY-SA 4.0
2019-06-07T01:52:30.283Z
That's too bad; is there a solution for Commerce 1?  Do I have to create a plugin for this?
biko
CC BY-SA 4.0
2019-06-06T18:16:46.073Z
2019-06-06T18:16:46.073Z
August Miller
<p>I want to assign different default order status based on product types.  Is this possible?</p>

<p>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?</p>

<plugin-craftcommerce><emails><order><status><products>
Commerce 1: Different default order status based on product types
# Commerce 1: Different default order status based on product types

(Asked by: username_0 on 2019-06-06)

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?

**Tags:** plugin-craftcommerce, emails, order, status, products

---

## 1 answers

### Answer by username_1 on 2019-06-06. Score: 2

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;

Event::on(
    OrderStatuses::class,
    OrderStatuses::EVENT_DEFAULT_ORDER_STATUS,
    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`.
    });

> **Comments:**
> **username_0**: That's too bad; is there a solution for Commerce 1?  Do I have to create a plugin for this?  

---

