如何让Magento在创建发货时发送短信

时间:2014-03-08 13:09:17

标签: magento sms

Magento在订单确认和发货时发送短信,我们有以下PHP代码:

   <?php 
$ch = curl_init(); 
$user="**@bindaaslo.com:**"; 
$receipientno="98910***"; 
$senderID="TEST SMS"; 
$msgtxt="this is test message , test"; curl_setopt($ch,CURLOPT_URL, "http://api.mVaayoo.com/mvaayooapi/MessageCompose"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "user=$user&senderID=$senderID&receipientno=$receipientno&msgtxt=$msgtxt"); $buffer = curl_exec($ch); if(empty ($buffer)) { echo " buffer is empty "; } else { echo $buffer; } curl_close($ch); 
   ?>

1 个答案:

答案 0 :(得分:0)

打开文件[magento]\app\code\core\Mage\Adminhtml\controllers\Sales\Order\ShipmentController.php

找到saveAction()并在其中添加代码

public function saveAction()
    {
        ......................

        $ch = curl_init(); 
        $user="**@bindaaslo.com:**"; 
        $receipientno="98910***"; 
        $senderID="TEST SMS"; 
        $msgtxt="this is test message , test"; curl_setopt($ch,CURLOPT_URL, "http://api.mVaayoo.com/mvaayooapi/MessageCompose"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "user=$user&senderID=$senderID&receipientno=$receipientno&msgtxt=$msgtxt"); $buffer = curl_exec($ch); if(empty ($buffer)) { echo " buffer is empty "; } else { echo $buffer; } curl_close($ch); 

        ......................
    }

注意:不要直接更改核心文件而不是覆盖控制器。

您可以通过观察者

实现相同目标

某些链接可帮助您为sales_order_shipment_save_before事件创建观察者

Magento - 2 or more observer on same event

https://magento.stackexchange.com/questions/847/hook-into-order-shipped-event-and-get-order-id-for-order-shipped