0

How do I change the order status NOT STATE after I create an invoice in Magento 2?

I created a custom status called Invoiced, assigned it to state processing.

Status code: processing[Invoiced]

When I submit an invoice I want the order to be assigned to this new status.

What additional steps do I need to do?

0

In your

Vendor\Module\etc\frontend\events.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="sales_order_invoice_pay">
        <observer name="invoice_pay_after" instance="Vendor\Module\Observer\InvoicePayAfter" />
    </event>
</config>

Vendor\Module\Observer\InvoicePayAfter.php

class InvoicePayAfter implements \Magento\Framework\Event\ObserverInterface
{
    public function execute(\Magento\Framework\Event\Observer $observer)
    {
       \\You Can get Your Order Here Now Change its Status using
        $observer->getOrder();
        \\Or Something Like that
    }
}
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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