Sending Some Info To An Url If $Mode = Update_Status

I want to send some basic info when I change status of order. I wrote the code in addons\myaddon\controllers\backend\orders.pre.php



if ($mode == 'update_status') {
$order_info = fn_get_order_info($_REQUEST['id']);
fn_set_notification('N', __('notice'), $order_info['order_id']);

}




Now I know that I can send some info by using this. I can get other information of order that I need. But I don't know how to send these information to an URL.



The URL is: [url=“http://www.suratkargo.com.tr/GonderiWebServiceGercek/service.asmx?WSDL”][b]http://www.suratkargo.com.tr/GonderiWebServiceGercek/service.asmx?WSDL[/b][/url]



I want to send some user and order information to this URL. (It's the URL of a shipping company.)



I need some help. You may show me an example code.

Use Tygh\Http class to make such requests. As an example, I can offer you to check the app/payments/sage_payment.php file (a part of the Sage payment method)


```php

......
use Tygh\Http;
if (!defined('BOOTSTRAP')) { die('Access denied'); }
$post_address = "https://gateway.sagepayments.net/cgi-bin/eftBankcard.dll?transaction";
$post = array();
$post['M_id'] = $processor_data["processor_params"]["merchant_id"];
$post['M_key'] = $processor_data["processor_params"]["merchant_key"];
$post['T_code'] ='01';
$post['T_ordernum'] = (($order_info['repaid']) ? ($order_id . $order_info['repaid']) : $order_id);
$post['T_amt'] = $order_info["total"];
......
// Post a request and analyse the response
$return = Http::post($post_address, $post);
........
```

Thank you. I got it. One more question: How can I test the data I send? How can I see response?

[quote name='ooaykac' timestamp='1420037366' post='201396']

Thank you. I got it. One more question: How can I test the data I send? How can I see response?

[/quote]



fn_print_r($return);

Reason you're not using the 'change_order_status' hook rather than catching it in a pre-controller? You could then act on the data only for the specific status changes (or any status). Note that status can be changed by other addons in the system without being in the 'orders' controller context.