Magento ver. 1.9.3.2
C:\xampp\htdocs\magento1\app\code\local\Maddy\Checkout\etc\config.xml
<?xml version="1.0"?>
<config>
<modules>
<Maddy_Checkout>
<version>0.0.1</version>
</Maddy_Checkout>
</modules>
<global>
<models>
<maddy>
<class>Maddy_Checkout_Model</class>
</maddy>
<events>
<sales_order_place_after>
<observers>
<maddy_sendsms>
<class>Maddy_Checkout_Model_Observer</class>
<method>orderSms</method>
<type>singleton</type>
</maddy_sendsms>
</observers>
</sales_order_place_after>
</events>
</global>
</config>
C:\xampp\htdocs\magento1\app\code\local\Maddy\Checkout\Model\Observer.php
<?php
class Maddy_Checkout_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'));
echo "I am here";
die;
/* I will write sms api here */
echo "Mobile" . $mobile;
echo "<script>alert('Just to check')</script>";
}
}
C:\xampp\htdocs\magento1\app\etc\modules\Maddy_Checkout.xml
<?xml version="1.0"?>
<config>
<modules>
<Maddy_Checkout>
<active>true</active>
<codePool>local</codePool>
</Maddy_Checkout>
</modules>
</config>
When order is placed no alert is shown.
UPDATE:
if I use event based trigger I am not able to do add to cart. If I delete this module g then add cart is working.There is no log for this.
UPDATE:1.1
After creating some observers i am came to know that never echo any thing directly in observers , even dump in log to see the output. It will not break the functionality than.