0
votes

Banging my head for the last two days but unable to achieve this. Help!!

Whenever a shipment email is communicated I want to trigger a code which will send a SMS to the customer informing him/her that his order has been dispatched and also communicate the tracking number.

The code will be something like this:

<?php 
$url = "http://www.abcde.in/binapi/pushsms.php?usr=xyz&pwd=abc&sndr=MEGYTR&ph=8888829554&text=This is test. MegaYtr&rpt=1";
$result = file_get_contents($url);
?>

Questions: 1) From where do I run this code?

2) How do I get additional info like Order Number, Customer Name, Grand Total & Tracking Number. I had done something similar for sending SMS when customer places order at that I used this code:

$order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$order_details = Mage::getModel('sales/order')->loadByIncrementId($order_id);
$shipping_address_data = $order_details->getShippingAddress();
$first_name = $shipping_address_data['firstname'];
$telephone = $shipping_address_data['telephone'];
$amount_paid = $order_details->total_paid;
$message = 'Dear '.$first_name.' thank you for shopping at abc.com. Your order'.$this->getOrderId().' amounting to Rs.'.$amount_paid.'is being processed.';
echo '<b>'.$message.' Please check your email for further details.</b>';

I am using Magento Community 1.7.0.1.

1
Built in functionality of this extension magecomp.com/magento-sms-notification.htmlGaurav Jain

1 Answers

1
votes

try this

i would like to give you an simple solution without need of modifying core files. for that you need to create an observer for SuccessAction below is the event that will trigger your code when an order is successfull

checkout_onepage_controller_success_action

this will help you in creating observer for the above event create observer using this

one more thing i would like to add is in the controller at location Mage/Checkout/OnepageController search for successAction, this is the Action which is processed on the succes of order. Here on line 240 if you comment $session->clear(); than you would not require to place order again and again, just by refreshing the page you can check your changes.

And lastly FYI above event will dispatch orderId by using that you can load the order object, for doing that the below is the code

//load order object
$_order = Mage::getModel('sales/order')->loadByIncrementId($order_id_from_observer);