【问题标题】:how to Magento sending SMS upon creating shipmentMagento 如何在创建货件时发送短信
【发布时间】:2014-03-08 13:09:17
【问题描述】:

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); 
   ?>

【问题讨论】:

标签: magento sms


【解决方案1】:

打开文件[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); 

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

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

或者

你也可以通过observer实现同样的目的

一些链接可帮助您为 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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-02-17
    • 1970-01-01
    • 2014-03-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-08
    • 1970-01-01
    相关资源
    最近更新 更多