1

How can i send a sms upon successful check out in magento , as i have a third party

sms api integrated already with another project , how can i give all the module as

a library or any other workaround for this in magento ?

2
  • can you show your sms api code?
    – Amit Bera
    Commented Feb 24, 2015 at 5:26
  • that is not in magento though ? so you want to see how i am sending the sms api url ?
    – KTM
    Commented Feb 24, 2015 at 5:32

2 Answers 2

2

Icecreamsandwich,you can do this by magento event observer.There are lot of event on order place

Just:

  1. checkout_submit_all_after
  2. checkout_onepage_controller_success_action
  3. sales_order_place_after

etc

Observer code:

<?php
class MyNameSpace_MyModule_Model_Observer
{
public function orderSms(Varien_Event_Observer $observer)
{
    $incrementId = $observer->getEvent()->getOrder()->getIncrementId();
    $custName = $observer->getEvent()->getOrder()->getCustomerFirstname();
    $orderPrice = $observer->getEvent()->getOrder()->getGrandTotal();
    $orderId = $observer->getEvent()->getOrder()->getId();
    $order= $observer->getEvent()->getOrder()
    $mobile =  trim($order->getShippingAddress()->getData('telephone'));
    /* write your Sms code */

}
}

You can use any one of this but depends on conditions.

Using sales_order_place_after event;

config.xml code is like:

<events>
    <sales_order_place_after>
    <observers>
        <amit_sms>
        <class>mymodule_model_prefix/observer</class>
        <method>orderSms</method>
        <type>singleton</type>
        </amit_sms>
    </observers>
    </sales_order_place_after>
</events>
5
  • Actually am a newbie in magento , where to put the observer code first ? In app\code\core\Mage\Checkout\Block\Sucess.php ?
    – KTM
    Commented Feb 24, 2015 at 5:57
  • Can you explain this in details pls
    – KTM
    Commented Feb 25, 2015 at 6:10
  • 1
    okay i done it as checkout_onepage_controller_success_action observer it works properly , whether it will work same for the sales_order_place_after observer too ? because i need to send sms only after placing the order .
    – KTM
    Commented Feb 26, 2015 at 8:37
  • Good .. @lcecreamsandwish
    – Amit Bera
    Commented Feb 26, 2015 at 8:42
  • Teja.do know about event observer
    – Amit Bera
    Commented Dec 24, 2015 at 11:21
1

1) For sending SMS on the successful checkout use following observer event.

<checkout_onepage_controller_success_action></checkout_onepage_controller_success_action>

in your sms module's config.xml.you need to create a module for this

<global>
    <events>
        <checkout_onepage_controller_success_action>
            <observers>
                <send_sms_on_order_success>
                    <type>singleton</type> 
                    <class>Yourpackage_SMS_Model_Observer</class> 
                    <method>order_success</method> 
                </send_sms_on_order_success>
            </observers>
        </checkout_onepage_controller_success_action>
    </events>
</global>

and in your module's observer.php file

class Yourpacakage_SMS_Model_Observer {
        public function order_success($observer){

            // sms code goes here

        }
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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