In Magento 2.3.0, I need to execute a specific function when the order is shipped (the Ship action is triggered).
Basically, I am using the 'sales_order_save_after' event to check what's the current status, but the results are different in two situations as follows:
- For a new order, if I generate the invoice first and the shipping process, the observer that is executed following the 'sales_order_save_after' event says that the current status is complete which is correct.
- For a new order, if I don't generate the invoice and I just hit the 'Ship' button, the observer that is executed following the 'sales_order_save_after' event says that the current status is processing and not complete.
Why is this happening and how can I get the complete event when I hit the 'Ship' button, without going through preliminary steps such as invoicing?