TransWikia.com

Change order status after invoice in Magento 2.3.3

Magento Asked on January 29, 2021

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?

2 Answers

use evnt sales_order_invoice_pay which is fired in both frontend and beckend.

VendorModuleetcevents.xml

<?xml version="1.0"?>
<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="VrinsoftShippingNoteToSupplierObserverInvoicePayAfter" />
    </event>
</config>

VendorModuleObserverInvoicePayAfter.php

<?php


 namespace VrinsoftShippingNoteToSupplierObserver;

 use MagentoFrameworkEventObserverInterface;
 use MagentoFrameworkEventObserver;

class InvoicePayAfter implements MagentoFrameworkEventObserverInterface

{
    public function execute(MagentoFrameworkEventObserver $observer)
    {
        $order = $observer->getEvent()->getInvoice();
        //echo json_encode($order->getData());exit();
    }
}

Answered by Jay Pipaliya on January 29, 2021

In your

VendorModuleetcfrontendevents.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="VendorModuleObserverInvoicePayAfter" />
    </event>
</config>

VendorModuleObserverInvoicePayAfter.php

class InvoicePayAfter implements MagentoFrameworkEventObserverInterface
{
    public function execute(MagentoFrameworkEventObserver $observer)
    {
       \You Can get Your Order Here Now Change its Status using
        $observer->getOrder();
        \Or Something Like that
    }
}

Answered by Waqar Ali on January 29, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP