I have been trying to create an Observer which automatically sends SMS whenever an invoice has been created by hooking into the:
sales_order_save_after
Now I am getting an error says: " a:5:{i:0;s:132:"Cannot send headers; headers already sent in /home2/uditgupta/public_html/app/code/local/Yng/AssignDealer/Model/Observer.php, line 4";i:1;s:1407:"#0 /home2/uditgupta/public_html/lib/Zend/Controller/Response/Abstract.php(148): Zend_Controller_Response_Abstract->canSendHeaders(true)
a:5:{i:0;s:132:"Cannot send headers; headers already sent in /home2/uditgupta/public_html/app/code/local/Yng/AssignDealer/Model/Observer.php, line 4";i:1;s:1407:"#0 /home2/uditgupta/public_html/lib/Zend/Controller/Response/Abstract.php(148): Zend_Controller_Response_Abstract->canSendHeaders(true)
"
Here is my code:
class Yng_AssignDealer_Model_Observer {
public function customerRegisterSuccess(Varien_Event_Observer $observer) {
$order = $observer->getEvent()->getOrder();
print_r($order->getData());
echo $ordid = $order['increment_id'];
$orderObj = Mage::getModel('sales/order')->loadByIncrementId($ordid);
print_r($orderObj);
$billing_info=$orderObj->getBillingAddress();
echo $mobile=$billing_info['telephone'];
echo $name=$billing_info['firstname'];
if($order['status']=="processing")
{
$msg='Hello';
$path='http://login.smsgatewayhub.com/';
$ch = curl_init($path);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,0);
curl_exec($ch);
curl_close($ch);
//echo $path;
}
if($order['status']=="complete")
{
$msg='Hello';
$path='http://login.smsgatewayhub.com/';
$ch = curl_init($path);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,0);
curl_exec($ch);
curl_close($ch);
//echo $path;
}
}
}
Please help. Many thanks in advance.
从代码中删除echo和print_r,然后检查
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.