简体   繁体   English

如何获得用于验证/发送SMS通知的客户电话号码,例如Magento新客户注册的电子邮件通知?

[英]How Can I get Customer telephone Number for verification/Send SMS Notification as like as email notification for Magento new Customer registration?

01.I try to get Customer Registration form action Here(I have already SMS Api & send sms via php script) 01.我尝试在此处获取“客户注册”表单操作(我已经有SMS Api并通过php脚本发送短信)

app/design/frontend/base/default/template/customer/form/register.phtml 应用程序/设计/前端/基/默认/模板/客户/表格/ register.phtml

form action="...getPostActionUrl() ..." method="post" 表单action =“ ... getPostActionUrl()...” method =“ post”

  1. sendNewAccountEmail app/code/core/Mage/Customer/Model/Customer.php Line==588 sendNewAccountEmail app / code / core / Mage / Customer / Model / Customer.php Line == 588

  2. Get protected function _welcomeCustomer in app/code/core/Mage/Customer/controllers/AccountController.php Line==517 在应用程序/代码/核心/法师/客户/控制器/AccountController.php中获取受保护的函数_welcomeCustomer。Line == 517

Which way i get new Customer telephone number or Send SMS Notification as like as email notification ? 我以哪种方式获得新的客户电话号码或像电子邮件通知一样发送SMS通知?

In Magento there is customer_register_success event trown when customer has been successfully registered. 在Magento中,成功注册客户后会出现customer_register_success事件。

For handling this even you need to create custom module with observer for this event. 为了处理此问题,您甚至需要使用该事件的观察者创建自定义模块。

  1. Creating Custom Module . 创建定制模块 ( Create new file YOUR_MODULE.xml in app\\etc\\modules folder ) (在app\\etc\\modules文件夹中创建新文件YOUR_MODULE.xml

Content of YOUR_MODULE.XML should look like : YOUR_MODULE.XML内容应类似于:

     <config>
       <modules>
         <YOUR_MODULE>
            <active>true</active>
            <codePool>local</codePool>
        </YOUR_MODULE>
      </modules>
   </config>
  1. Creating Config File . 创建配置文件 ( Create config.xml in app\\code\\local\\YOUR\\MODULE\\etc folder ) (在app\\code\\local\\YOUR\\MODULE\\etc文件夹中创建config.xml

Content of config.XML should look like : config.XML内容应类似于:

<config>
    <modules>
    <YOUR_MODULE>
        <version>0.1.0</version>
    </YOUR_MODULE>
    </modules>
    <global>
    <models>
        <YOUR_MODULE>
        <class>YOUR_MODULE_Model</class>
        </YOUR_MODULE>
    </models>
    <events>
        <customer_register_success>
        <observers>
            <YOUR_MODULE>
            <type>singleton</type>
            <class>YOUR_MODULE/observer</class>
            <method>SendSMS</method>
            </YOUR_MODULE>
        </observers>
        </customer_register_success>
    </events>
    </global>
</config>
  1. Creating Observer . 创建观察者 ( Create observer.php in app\\code\\local\\YOUR\\MODULE\\Model\\ folder ) (在app\\code\\local\\YOUR\\MODULE\\Model\\文件夹中创建observer.php

Content of observer.php should look like : observer.php内容应如下所示:

<?php
class YOUR_MODULE_Model_Observer
{
    public function SendSMS($observer)
    {
        $customer = $observer->getEvent()-getCustomer();
        $TelephoneNo = $customer->getTelephone(); 
        // At this point you can send this number to your SMS API
    }
}
?>

What you could do is attach an observer to the event customer_save_after . 您可以做的是将观察者附加到事件customer_save_after This will be fired everytime the customer is saved. 每次保存客户时都会触发该事件。 You will then need to validate if the customer is a new creation. 然后,您将需要验证客户是否是新创建的客户。

Then at this point you can trigger the getting of the telephone number and the sending of the sms. 然后,此时您可以触发电话号码的获取和短信的发送。

If you want to completely replace the emails with an sms then I would suggest rewriting the classes and replacing the welcome email sending functions with smsm sending functions. 如果您想用短信完全替换电子邮件,则建议重写类,并用短信发送功能替换欢迎电子邮件发送功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM