Reputation: 33
I want to send a notification SMS to customers when I change order delivery status from admin panel, purchased SMS service from India
Upvotes: 0
Views: 1619
Reputation: 5670
You need to check the order status for changing - there is no event for this so you need:
Event: sales_order_load_after
to get the order status after load
Method:
public function fetchOrderStatus(Varien_Event_Observer $observer){
try{
if (!Mage::registry('cartware_order_status')){
Mage::register('cartware_order_status', $observer->getOrder()->getStatus());
}
}
catch (Exception $e){
Mage::logException("UNEXPECTED PROBLEM WIH REGISTER");
Mage::logException($e);
}
return;
}
Event: sales_order_save_after
to get the order status after save:
Method:
public function checkOrderStatus(Varien_Event_Observer $observer){
try{
if(!Mage::registry('cartware_order_status')){
return;
}else{
$orderStatus = Mage::registry('cartware_order_status');
}
}
catch (Exception $e){
Mage::logException("UNEXPECTED PROBLEM WIH REGISTRY");
Mage::logException($e);
}
if ($orderStatus != $observer->getOrder()->getStatus() &&
$observer->getOrder()->getStatus() == [STATUS YOU WANT TO REACT IF CHANGE TO]){
sendYourSmsMethod();
}
}
Good luck!
Upvotes: 1