Magento – Magento 2 – Change Order status after invoicing

invoicemagento2order-status

I have an observer that triggered on sales_order_invoice_pay event, and after creating the invoice, the order status is automatically changed to complete. after that I try to change it to processing but it doesn't work.

is there any way to change the order status after creating the invoice?

below is the code I use to change the status:

$order->setState(\Magento\Sales\Model\Order::STATE_PROCESSING, true);
                    $order->setStatus('processing');
                    $this->_orderRepository->save($order);

Best Answer

I think this is cover of your requirement.

from admin panel Order statuses cannot be changed, as it disrupts the business logic of Magento itself.

Generally, it’s only possible to cancel, hold and unhold pending orders.

If you want to cancel an order with a ‘Processing’ status or ‘Complete" status you will have to create a credit note for this.

For more info you can look here https://www.mag-manager.com/useful-articles/magento-orders-management/magento-change-order-status-to-any-from-any/

Related Topic