Skip to main content
1 of 2

It is good and you followed good approach as per M2 standards. It needs some improvement to make it compatible and error-free in maximum of cases

  1. Exception Handling.

    $order = $observer->getEvent()->getOrder(); if( !empty($order) ){ // do code here }

  2. Naming convention. Do use camel-case for variables. $order_status should be $orderStatus.

  3. It is observer so you wont be able to track if that happened or not so do wrap it in try-catch and log accordingly ( do add check if logs are enabled or not ).