Sending Correct Order Status To Customer As Email

I preparted the code and put it under /app/addons/my_changes/controllers/frontend in checkout.post.php file.



I changed order status according to the payment method. So, if the customer chooses the payment method that ID is 3, the order status is changed and saved with new changed order status I set. For example if payment method 3 be selected, the order status “K” is saved.



Everything is OK till here. But, there is a problem about email: Content of order status marked with “O”, wich means OPEN, is being sent to customer as email. But I want content of order status “K” to be sent.



How can I provide the correct email is being sent?



Here is the code I wrote:



if( $_SERVER['REQUEST_METHOD'] != 'POST' && $mode == 'complete' ) { //If mode is complete
$order_info = fn_get_order_info($_REQUEST['order_id']);
//fn_print_die($order_info);

if ( !empty($order_info['payment_id'])) {

// Change order status
$valid_id = db_get_field("SELECT order_id FROM ?:order_data WHERE order_id = ?i ", $order_info['order_id']);
if (!empty($valid_id)) {
db_query("DELETE FROM ?:order_data WHERE order_id = ?i", $order_info['order_id']);
fn_update_order_payment_info($order_info['order_id'], $pp_response);

if ( $order_info['payment_id'] == '3' ) {
$pp_response['order_status'] = 'K';
} elseif ( $order_info['payment_id'] == '4' ) {
$pp_response['order_status'] = 'L';
}

fn_set_hook('finish_payment', $order_info['order_id'], $pp_response, $force_notification);
fn_change_order_status($order_info['order_id'], $pp_response['order_status'], '', $force_notification);
}
}

}

[quote name='ooaykac' timestamp='1419059100' post='200412']

I preparted the code and put it under /app/addons/my_changes/controllers/frontend in checkout.post.php file.



I changed order status according to the payment method. So, if the customer chooses the payment method that ID is 3, the order status is changed and saved with new changed order status I set. For example if payment method 3 be selected, the order status “K” is saved.



Everything is OK till here. But, there is a problem about email: Content of order status marked with “O”, wich means OPEN, is being sent to customer as email. But I want content of order status “K” to be sent.



How can I provide the correct email is being sent?



Here is the code I wrote:

[/quote]



Try to replace



fn_change_order_status($order_info['order_id'], $pp_response['order_status'], '', $force_notification);




with



fn_change_order_status($order_info['order_id'], $pp_response['order_status'], '', true);




Note that even in this the customer will receive two e-mail. The first one will be default (with the Open status), and the second one is yours.

[quote name='eComLabs' timestamp='1419239912' post='200539']

Try to replace



fn_change_order_status($order_info['order_id'], $pp_response['order_status'], '', $force_notification);




with



fn_change_order_status($order_info['order_id'], $pp_response['order_status'], '', true);




Note that even in this the customer will receive two e-mail. The first one will be default (with the Open status), and the second one is yours.

[/quote]



Thank you.


  1. What is difference between “$force_notification” and “true” at the and of the code line?


  2. I think, because I use php hook and add some more proccess except the core system of cs cart, the customer receive two emails. One is send by cs cart core system, one is send by the php hook I add.(above)

    Question: How can I prevent customer from receiving two emails. I only want them receive correct status email, not OPEN status.

Good day,



The 4th parameter means user notification flag (true/false), if not set, it is retrieved from status parameters.



It is better to use the change_order_status hook in the fn_change_order_status function which is located in the app/functions/fn.cart.php file for your needs.