Update status

Hi all,



I want to add an “action” if people change the status (see att) in Orders Details.

So if people select the C status do that.


  1. In which page(s) can i do that?
  2. And is it a post or a get?



    Kind regards,

    Bas

    ajax.jpg

/controllers/admin/orders.php



You'll find the answers in there.

Hi StellarBytes,



Thanks for your reply.

I have tried that, but i need also the oder_id and email param for the script below.

Do you know how to add that to the script below?





if($_REQUEST['status'] == 'C'){

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, “http://URL/feedback?action=sendInvitation&connector=16478899&user=EMAILPARAM&delay=0&remindDelay=0&resendIfDouble=1&orderNumber=ORDERNRPARAM”);

curl_setopt($ch, CURLOPT_HEADER, 0);

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

curl_setopt($ch, CURLOPT_NOPROGRESS, true);

curl_exec($ch);

curl_close($ch);

}



I hope you can help me.



Kind regards,

Bas

Hi,

Is better to use hooks,

You can easy hook to change_order_status and you have all details you need ($status_to, $status_from, $order_info, $force_notification, $order_statuses, $place_order)


function fn_my_changes_change_order_status($status_to, $status_from, $order_info, $force_notification, $order_statuses, $place_order)
{
if($status_to == 'C'){
$order_id = $order_info['order_id'];
$email = $order_info['email'];
...
}
}




I hope that helps,



Vali

Hi Vali,

Thanks for your reply!

How and where can I implement this?





I am new at CS Cart, and i hope you can help me how to do this.

Kind regards ,

Bas





[color=#000088][size=2]function[/size][/color][color=#000000][size=2] fn_my_changes_change_order_status[/size][/color][color=#666600][size=2]([/size][/color][color=#000000][size=2]$status_to[/size][/color][color=#666600][size=2],[/size][/color][color=#000000][size=2] $status_from[/size][/color][color=#666600][size=2],[/size][/color][color=#000000][size=2] $order_info[/size][/color][color=#666600][size=2],[/size][/color][color=#000000][size=2] $force_notification[/size][/color][color=#666600][size=2],[/size][/color][color=#000000][size=2] $order_statuses[/size][/color][color=#666600][size=2],[/size][/color][color=#000000][size=2] $place_order[/size][/color][color=#666600][size=2])[/size][/color]

[color=#666600]{[/color]

[color=#000000] [/color][color=#000088]if[/color][color=#666600]([/color][color=#000000]$status_to [/color][color=#666600]==[/color][color=#000000] [/color][color=#008800]'C'[/color][color=#666600]){[/color]

[color=#000000] $order_id [/color][color=#666600]=[/color][color=#000000] $order_info[/color][color=#666600][[/color][color=#008800]'order_id'[/color][color=#666600]];[/color]

[color=#000000] $email [/color][color=#666600]=[/color][color=#000000] $order_info[/color][color=#666600][[/color][color=#008800]'email'[/color][color=#666600]];[/color]

[color=#000000] [/color]

[font=arial, verdana, tahoma, sans-serif]$ch = curl_init();[/font]

[font=arial, verdana, tahoma, sans-serif]curl_setopt($ch, CURLOPT_URL, “http://URL/feedback?action=sendInvitation&connector=16478899&user=[/font][color=#000000]$email[/color][font=arial, verdana, tahoma, sans-serif]&delay=0&remindDelay=0&resendIfDouble=1&orderNumber=[/font][color=#000000]$order_id[/color][font=arial, verdana, tahoma, sans-serif]”);[/font]

[font=arial, verdana, tahoma, sans-serif]curl_setopt($ch, CURLOPT_HEADER, 0);[/font]

[font=arial, verdana, tahoma, sans-serif]curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);[/font]

[font=arial, verdana, tahoma, sans-serif]curl_setopt($ch, CURLOPT_NOPROGRESS, true);[/font]

[font=arial, verdana, tahoma, sans-serif]curl_exec($ch);[/font]

[font=arial, verdana, tahoma, sans-serif]curl_close($ch); [/font]



[color=#000000] [/color][color=#666600]}[/color]

[color=#666600]}[/color]

create if not exist :[list]

[]addons/my_changes/func.php

[
]addons/my_changes/init.php

[/list]

add into init.php

```php

if ( !defined('AREA') ) { die('Access denied'); }
fn_register_hooks(
'change_order_status'
);
?>

```



add into func.php

if ( !defined('AREA') ) { die('Access denied'); }

function fn_my_changes_change_order_status($status_to, $status_from, $order_info, $force_notification, $order_statuses, $place_order)
{
if($status_to == 'C'){
$order_id = $order_info['order_id'];
$email = $order_info['email'];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://URL/feedback?action=sendInvitation&connector=16478899&user=$email&delay=0&remindDelay=0&resendIfDouble=1&orderNumber=$order_id");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_NOPROGRESS, true);
curl_exec($ch);
curl_close($ch);
}
}

Hi Vali,



Thanks for your reply!

If i change the status the script executed well, but i am getting a pasre error?! See attachement.

Do you know what that can be?



Kind regards,

Bas

error.jpg

you change the ?

http://URL

[size=3]This is the full url, it works but i am getting that error…[/size]



[size=3]curl_setopt($ch, CURLOPT_URL, “http://connect.feedbackcompany.nl/feedback?action=sendInvitation&connector=16478899&user=$email&delay=0&remindDelay=0&resendIfDouble=1&orderNumber=[color=#000000]$order_id[/color]”);[/size]

[quote name='Bas D L' timestamp='1358590118' post='153166']

[size=3]This is the full url, it works but i am getting that error…[/size]



[size=3]curl_setopt($ch, CURLOPT_URL, “http://connect.feedbackcompany.nl/feedback?action=sendInvitation&connector=16478899&user=$email&delay=0&remindDelay=0&resendIfDouble=1&orderNumber=[color=#000000]$order_id[/color]”);[/size]

[/quote]



please try this, i have tested and works just fine


function fn_my_changes_change_order_status($status_to, $status_from, $order_info, $force_notification, $order_statuses, $place_order)
{
if($status_to == 'C'){
$order_id = $order_info['order_id'];
$email = $order_info['email'];
$url = "http://connect.feedbackcompany.nl/feedback?action=sendInvitation&connector=XXXXXXXX&user=$email&delay=0&remindDelay=0&resendIfDouble=1&orderNumber=$order_id";
fn_set_notification('N', fn_get_lang_var('notice'), 'LINK created: '.$url ); //if you don't wish notificatio you can comment this line
list($header, $_result) = fn_http_request('GET', $url);

}
}


just replace XXXXXXXX

Hi,



Thanks again for your reply. Unfortunately this does not work. The url doesn’t execute :-(



I have tried this and it works whitout errors, is that also a good way?





function fn_my_changes_change_order_status($status_to, $status_from, $order_info, $force_notification, $order_statuses, $place_order)

{

if($status_to == ‘C’){

$context = stream_context_create(array(‘http’ => array(‘header’=>‘Connection: close\r\n’)));

file_get_contents(“http://connect.feedbackcompany.nl/feedback?action=sendInvitation&connector=16478899&user=12345678@12345678.nl&delay=0&remindDelay=0&resendIfDouble=1&orderNumber=123456789”,false,$context);

}

}



Kind regards,

Bas

Same error?

Do you have documentation over connect.feedbackcompany.nl, if yes please PM me and i will do my best to help you

When i use this it works!



[color=#282828][font=arial, verdana, tahoma, sans-serif]function fn_my_changes_change_order_status($status_to, $status_from, $order_info, $force_notification, $order_statuses, $place_order)[/font][/color]

[color=#282828][font=arial, verdana, tahoma, sans-serif]{[/font][/color]

[color=#282828][font=arial, verdana, tahoma, sans-serif]if($status_to == 'C'){[/font][/color]

[color=#282828][font=arial, verdana, tahoma, sans-serif]$context = stream_context_create(array('http' => array('header'=>'Connection: close\r\n')));[/font][/color]

[color=#282828][font=arial, verdana, tahoma, sans-serif]file_get_contents(“http://connect.feedbackcompany.nl/feedback?action=sendInvitation&connector=16478899&user=12345678@12345678.nl&delay=0&remindDelay=0&resendIfDouble=1&orderNumber=123456789”,false,$context);[/font][/color]

[color=#282828][font=arial, verdana, tahoma, sans-serif]}[/font][/color]

[color=#282828][font=arial, verdana, tahoma, sans-serif]}[/font][/color]

Check with


function fn_my_changes_change_order_status($status_to, $status_from, $order_info, $force_notification, $order_statuses, $place_order)
{
if($status_to == 'C'){
$context = stream_context_create(array('http' => array('header'=>'Connection: close\r\n')));
file_get_contents("http://connect.feedbackcompany.nl/feedback?action=sendInvitation&connector=16478899&user=".$order_info['email']."&delay=0&remindDelay=0&resendIfDouble=1&orderNumber=".$order_info['order_id'],false,$context);
}
}

Thanks for the good help Vali!

You are welcome.



I'm glad i could help you





Vali