2

I want to send SMS when customer register success, I use customer_register_success magento event not working. But when i use customer_address_save_after magento sms sending but problem here every time change address customer get sms alert.

How can i use customer_register_success event only for customer register success

\app\etc\modules\Sslw_Ismsregister.xml

<?xml version="1.0" encoding="UTF-8"?>      
        <config>
            <modules>
                <Sslw_Ismsregister>
                    <codePool>local</codePool>
                    <active>true</active>
                </Sslw_Ismsregister>
            </modules>
        </config>

app\code\local\Sslw\Ismsregister\etc\config.xml

<?xml version="1.0" encoding="UTF-8"?>
        <config>
            <modules>
                <Sslw_Ismsregister>
                    <version>0.0.1</version>
                </Sslw_Ismsregister>
            </modules>
            <global>
                <models>
                    <sslwismsregister>
                        <class>Ismsregister_Model</class>
                    </sslwismsregister>
                </models>
                <events>
                    <customer_register_success>
                        <observers>
                            <Sslw_Ismsregister_model_observer>
                                <type>singleton</type>
                                <class>Sslw_Ismsregister_Model_Observer</class>
                                <method>SendSmsRegister</method>
                            </Sslw_Ismsregister_model_observer>
                        </observers>
                    </customer_register_success> 
                </events>
            </global>
        </config>

app\code\local\Sslw\Ismsregister\Model\Observer.php

 class Sslw_Ismsregister_Model_Observer {
            public function SendSmsRegister(Varien_Event_Observer $observer) {  
              Mage::log('customer_register_success '.'Mobile==',null,'SendSmsRegister001.log' );  //No log created 
              $msisdn = $observer->getCustomerAddress()->getTelephone();
               Mage::log('customer_register_success '.'Mobile=='.$msisdn,null,'SendSmsRegister00.log' );
//NOT Create Log here for this event

            //START SMS API Code here your code here    

          //ENd SMS API Code here your code   
            }

        }

customer_address_save_after magento sms sending (SMS API Working Properly) but problem here every time change address customer get sms alert Module Code below: Just change customer_address_save_after==>customer_register_success https://github.com/SSLWireless/MagentoSMS/tree/master/Magento_SendIsmsRegister/app

Magento Events Cheat Sheet (1.9) List:

https://www.nicksays.co.uk/magento-events-cheat-sheet-1-9/

  • customer_register_success event is fired when a customer registers on the website. It is possible to do so without having an address at all. So, event would be working, just you are not having the mobile number where you can send SMS. – Prateek Jan 28 '16 at 6:43
  • Just after SendSmsRegister function i put log that not work Mage::log('customer_register_success '.'Mobile==',null,'SendSmsRegister001.log' ); @Prateek if my function work then i can send sms – matinict Jan 28 '16 at 6:52
  • Try with putting the event in <frontend> scope from the global scope. Also, not relevant, but you have defined the models node incorrectly in your config. – Prateek Jan 28 '16 at 6:57
  • i think it correct my another event work properly when i just change event customer_address_save_after function create log & working properly . @Prateek you may check that already using live site github.com/SSLWireless/MagentoSMS/tree/master/… – matinict Jan 28 '16 at 6:59
  • Check this link : magento.stackexchange.com/questions/69067/… – Prateek Jan 28 '16 at 7:02
2

I got my solution describe flowing:

magento customer registration 2 way 1. Create Account directly from sinup form 2. Create account order checkout time

The Above module work only for customer_register_success observers events work when customer Create Account directly from sinup form.

When customer create account order checkout time we need to add flowing

Add following Line Top of success.phtml

    // Retrieve order
    //$_order = new Mage_Sales_Model_Order();
    //$orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
    //$_order->loadByIncrementId($orderId);

    // Start Send Emai Here......
    $order = new Mage_Sales_Model_Order();
    $incrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); 
    $order->loadByIncrementId($incrementId);

   //Start New Customer Registration SMS Here           
    $customerAddressId = Mage::getSingleton('customer/session')->getCustomer()->getDefaultBilling();
    $address = Mage::getModel('customer/address')->load($customerAddressId);
    $msisdn = $address->getTelephone();                     
    $quoteId = $order->getQuoteId();
    $quote = Mage::getModel('sales/quote')->load($quoteId);
    $method = $quote->getCheckoutMethod(true);
    $customer_email = $order->getCustomerEmail();
    if ($method == 'register'){ 
    //code to handle if customer just registered to your site
    //START SMS API Code here your code

    //ENd SMS API Code here your code

     } elseif($method == 'guest') {
    //code to handle if customer is guest
     } else {                
    //code to handle for logged in customer
     }  
   //END New Customer Registration SMS Here  

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.