Send Order data to other Server After Successful Order In Magento

To update our store orders on some other website other than our magento store we need to send the orders details after successful order at our store.To do this we need to dispatch a method after success action. So we need to create a module in our ocal folder of magento . Here our module name is Postdata with package name Letsknnowit OR we can write this code in any other module also. We need to write some code in config.xml and Observer.php
File: app/code/local/Letsknowit/Checkout/etc/config.xml
<config>
<global>
<models>
<letsknowit_checkout>
<class>Letsknowit_Checkout_Model</class>
</letsknowit_checkout>
</models>
<events>
<checkout_onepage_controller_success_action>
<observers>
<postDataTosServer>
<type>singleton</type>
<class>Letsknowit_Checkout_Model_Observer</class>
<method>postDataTosServer</method>
</postDataTosServer>
</observers>
</checkout_onepage_controller_success_action>
</events>
</global> </config>
After successfull order in magento the observer is dispatched . In observer.php we will get the order details and send it to the url of other server via CURL method.
File: app/code/local/Letsknowit/Checkout/Model/Observer.php
<?php
class Letsknowit_Postdata_Model_Checkout_Observer
{
public function postDataTosServer(Varien_Event_Observer $observer){
$orderIds = $observer->getData('order_ids');
foreach($orderIds as $_orderId){
$order = Mage::getModel('sales/order')->load($_orderId);
$customer = Mage::getModel('customer/customer')->load($order->getData('customer_id'));
$customer->getDefaultBillingAddress()->getLastname();
$billingaddress = $order->getBillingAddress();
try { /* parameters can be change according to requirment */
$params = array( 'customerName'=>$order->getData('customer_firstname'),
'companyName'=>$billingaddress->getData('company'),
'telephone'=> $billingaddress->getData('telephone'),
'email'=> $billingaddress->getData('email'),
'street'=> $billingaddress->getData('street'),
'city'=> $billingaddress->getData('city'),
'region'=> $billingaddress->getData('region'),
'postcode'=> $billingaddress->getData('postcode'),
'total'=>$order->getGrandTotal() );
$url= 'exmaple.com/getorders.php'; // the url on which the data will be send through curl
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_HEADER);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
$response = curl_exec($ch);
curl_close($ch);
Mage::log('Order has been sent to exmaple.com');
} catch (Exception $e) {
Mage::logException($e);}
}
return $this;
}
}?>
To download the sample code click here

All your hard work is much appreciated. Nobody can stop to admire you. Lots of appreciation. 加密货币交易
Our Escorts in Delhi are not just beautiful—they’re skilled in the art of seduction. Enjoy a flawless adult night full of romance and erotic play.

Thanks for a very interesting blog. What else may I get that kind of info written in such a perfect approach? I’ve a undertaking that I am simply now operating on, and I have been at the look out for such info.situs toto
Nice post! This is a very nice blog that I will definitively come back to more times this year! Thanks for informative post. Lago Maggiore Webcam

The Slope Run controls are generally simple, often using arrow keys or A/D keys on a keyboard for browser versions, or tilt/drag controls on mobile devices.

Merely wanna input that you have a very nice web site , I love the pattern it actually stands out. chat-avenue

Water slide, large water play park, rollover trampolines and a large beach with sunbathing lawn Lido Cannobio with Acqualand Cannobio Cannobio Foil

Water slide, large water play park, rollover trampolines and a large beach with sunbathing lawn Lido Cannobio with Acqualand Cannobio
The Chipotle Kids Menu is perfect for smaller appetites, even for adults. I got all the nutritional info from the Chipotle Menu with Prices.

The quick, single-touch control Curve Rush is genius. Simple, but keeps you coming back for more challenges!

The Escorts Mahipalpur Enjoy the beauty and charm of Russian escorts with our special agency in Mahipalpur. Our crew of gorgeous call girls are at your disposal for incall and outcall bookings, offering a discreet and enjoyable service.

In this particular article, you will see a summary, satisfy browse this post. Chiropractor near Me

i like to make ice cream and sandwiches when playing papa's games

This is very appealing, however , it is very important that will mouse click on the connection: 代写

For true fans of this thread I will address is a free online! AITELEPHONE
Please rotate your device
We don't support landscape mode on your device. Please rotate to portrait mode for the best view of our site