0

I am beginner to magento & trying to develop a module for sending message when any order placed, with this module i am able to generate(send/recive) message but check out page not redirect to success page

etc/config.php

<?xml version="1.0"?>
<config>
    <modules>
        <Abc_Sms>
            <version>0.0.1</version>
        </Abc_Sms>
    </modules>
    <global>
        <models>
            <abc_sms>
                <class>Abc_Sms_Model</class>
            </abc_sms>
        </models>
         <events>
            <sales_order_place_before><!-- observe the event -->
                <observers>
                    <abc_sms>
                        <class>abc_sms/observer</class>
                        <method>newCheckout</method>
                    </abc_sms>
                </observers>
            </sales_order_place_before>
        </events>
    </global>
</config>

Model/Oberver.php

<?php 
class Abc_Sms_Model_Observer
{
    public function newCheckout($observer)
    {
        $order_id = $observer->getEvent()->getOrder()->getId();
        $order_no = $observer->getEvent()->getOrder()->getIncrementId();
        $order = Mage::getModel("sales/order")->load($order_id);

        $billing_address = $order->getBillingAddress(); 
        $billing_telephone = $billing_address->getTelephone();

        $msg = "Thank you for your purchase! Your order # is: ".$order_no;
        //sms api start

        $ch = curl_init();
        $user="****@gmail.com:****";
        $receipientno = $billing_telephone; 
        $senderID="TEST SMS"; 
        $msgtxt = $msg; 
        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);
        //sms api 
    }    
}
?>

Thanks in Advance for help

16
  • enable log and check error
    – Keyul Shah
    Commented Feb 3, 2015 at 13:10
  • are you able to log in the observer's newcheckout function Commented Feb 3, 2015 at 13:11
  • you are using <sales_order_place_before> try to use <sales_order_place_after> in the config Commented Feb 3, 2015 at 13:12
  • are you able to log anything in the log file in the newcheckout function ? Commented Feb 3, 2015 at 13:19
  • i already use both <sales_order_place_before> & <sales_order_place_after> & also used these events <checkout_type_onepage_save_order> &<checkout_type_onepage_save_order_after> because my theme using one page checkout but result is same
    – Dinesh
    Commented Feb 3, 2015 at 13:24

2 Answers 2

1

In your etc/config.xml

You should use

<sales_order_place_after> 

instead of

<sales_order_place_before>

Cheers :-)

1
<events>
    <sales_order_place_after><!-- observe the event -->
        <observers>
            <abc_sms>
                <class>abc_sms/observer</class>
                <method>newCheckout</method>
            </abc_sms>
        </observers>
    </sales_order_place_after>
</events>

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.