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
aryan
25th October 2025
While revolutionary in concept, the ultimate efficiency of the RTPS Bihar portal is constrained by the need for robust backend integration and the diligence of ground-level officers to verify and approve applications promptly.
aryan
25th October 2025
While the online accessibility of the Bihar Bhumi land record is a massive convenience, the underlying challenge remains the meticulous correction of old, inaccurate manual entries into the digital format.
Henry
23rd October 2025
Nice post! This is a very nice blog that I will definitively come back to more times this year! Thanks for informative post. judi bola
NoreenRogers12
18th October 2025
When your website or blog goes live for the first time, it is exciting. That is until you realize no one but you and your. ë ˆí”Œë¦¬ì¹´
kash
18th October 2025
BDG Game is creating a buzz among online players with its quick results and fun features. It combines strategy and entertainment in one platform. The login process is easy, and users can start predicting right away. I think BDG Game is perfect for those looking for fast-paced gaming excitement.
Harry
14th October 2025
The crafting possibilities are endless in Infinite Craft Recipes. Every element can combine in a multitude of ways, leading to new creations and endless surprises.
Naeem
12th October 2025
At the end of the day, every growth tactic has pros and cons. The idea to buy instagram followers cheap is one of the most debated. It may boost numbers, but true influence comes from connection and trust.
NoreenRogers12
2nd October 2025
I read a article under the same title some time ago, but this articles quality is much, much better. How you do this.. ì‹ ìš©ì¹´ë“œí˜„ê¸ˆí™”
I read a article under the same title some time ago, but this articles quality is much, much better. How you do this.. 먹튀검ì¦ì‚¬ì´íЏ
alice
24th September 2025
If you're looking for a survival horror game with a unique and chilling atmosphere, 99 Nights in the Forest would be an unforgettable journey.
NoreenRogers12
7th September 2025
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.
NoreenRogers12
31st July 2025
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
Tom
25th June 2025
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.
naveed
6th June 2025
Merely wanna input that you have a very nice web site , I love the pattern it actually stands out. chat-avenue
Post Your Message