0

I have created order with status pending and state new when i am creating invoice with not capture than status is processing and same for creating ship. i want to change order status after shipping to shipped.

0

i Got answer

create observer on sales_order_shipment_save_after event

    <?xml version="1.0"?>
    <!--
    /**
     * Copyright © 2016 Magento. All rights reserved.
     * See COPYING.txt for license details.
     */
    -->
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">

        <event name="sales_order_shipment_save_after">
            <observer name="tenx_sales_order_shipment_save_after" instance="Tenx\SalesExt\Observer\SalesOrderShipmentSaveAfter" />
        </event>
    </config>

create observer.

 public function execute(\Magento\Framework\Event\Observer $observer) {

        $shipment = $observer->getEvent()->getShipment();
        /** @var \Magento\Sales\Model\Order $order */
        $order = $shipment->getOrder();
        /*$order->setState(\Magento\Sales\Model\Order::STATE_PENDING_PAYMENT, true);
        $order->setStatus(\Magento\Sales\Model\Order::STATE_PENDING_PAYMENT);
        $order->addStatusToHistory($order->getStatus(), 'Order processed successfully with reference');
        $order->save();

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.