3

Hello I am unable to get the order status in the observer sales_order_place_after I also tried other events like checkout_onepage_controller_success_action, checkout_type_onepage_save_order_after. Here is my code

<global>
<models>
  <xyz_customorderstatusmodel>
    <class>Endive_CustomOrderStatus_Model</class>
  </xyz_customorderstatusmodel>
</models>
<events>

  <checkout_submit_all_after>
    <observers>
      <xyz_CustomOrderStatus_Model_Observer>
        <type>singleton</type>
        <class>xyz_customorderstatusmodel/observer</class>
        <method>implementOrderStatus</method>
      </xyz_CustomOrderStatus_Model_Observer>
    </observers>
  </checkout_submit_all_after>
</events>

public function implementOrderStatus(Varien_Event_Observer $observer){
    $mytime = "time - " . date('d-m-Y H:i:s');
    Mage::log('in me');
    $status = $observer->getEvent()->getOrder()->getStates();
    Mage::log('My variable : '.$mytime .' -- ' .$status);
    die;

 }
  • I post answer kindly check. – Dhiren Vasoya Aug 10 '18 at 14:27
3

You need to replace your code like this.

public function implementOrderStatus(Varien_Event_Observer $observer)
{
    $status = $observer->getEvent()->getOrder()->getStatus();
}
2

Try the below code instead of yours:

public function implementOrderStatus(Varien_Event_Observer $observer){
    $status = $observer->getEvent()->getOrder()->getStatusLabel();
}

$observer->getEvent()->getOrder()->getStatusLabel(); This will return Status label like (Pending, Processing etc)

$observer->getEvent()->getOrder()->getStatus(); This will return Status Code(field values as in database) only like (pending, processing etc.)

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.