I want to change order status according to the payment method. If the customer chooses the payment method that ID is 3, the order status has to change and be saved with new changed order status…
I preparted the code and put it under /app/addons/my_changes/controllers/frontend in checkout.post.php file.
But I couldn’t add the right code to necessary area. I need HELP.
<br />
use Tygh\Registry;<br />
if( !defined('AREA') ) {die('Access denied'); }<br />
$cart = & $_SESSION['cart'];<br />
if (isset($cart['payment_id'])) {<br />
$payment_method_data = fn_get_payment_method_data($cart['payment_id']);<br />
}<br />
$order_info = fn_get_order_info($_REQUEST['order_id']);<br />
<br />
if( $_SERVER['REQUEST_METHOD'] != 'POST' && $mode == 'complete' ) { //I am not sure what mode I should use. complate or checkout?<br />
if ($payment_method_data['payment_id']==3) {<br />
<br />
<br />
/*** SOME CODES HERE***/<br />
<br />
<br />
}<br />
<br />
<br />
//fn_print_die($order_info);<br />
<br />
<br />
}<br />
return array(CONTROLLER_STATUS_OK);<br />
Use the change_order_status hook instead (lot easier). It will pass you the status being changed to, possibly the status being changed from, the order_id and even the list of current statuses.
You'd look at the status being changed to. if 'P', then look at the payment method and adjust it to whatever you want.
But there is a problem: If I put “fn_print_die($order_id);” the order status changes to status “K”. But when I remove this line the status doesn't change to “K”, it stays as it: “O”
You are setting the value in a variable that is never seen by the caller. Again, suggest you either modify the payment method script itself or use the change_order_status hook. The place_order hook is called before the payment is processed. Hence it's being overwritten when the payment processor is called.
You are setting the value in a variable that is never seen by the caller. Again, suggest you either modify the payment method script itself or use the change_order_status hook. The place_order hook is called before the payment is processed. Hence it's being overwritten when the payment processor is called.
[/quote]
Understand. Now, I am trying to use “change_order_status”. But although I am working on it about 3 days, I couldn't do it. Could you show me an examle code?
Sorry, I can't turn a merchant into a developer. Suggest you hire a developer with the appropriate skills to do the work you need done. It is development work.
It would also help to understand the business need for this change. I.e. what are you accomplishing with it in the operation of your business?
Ill need to try this as we have a need to create a “Quotation” payment method. I found that it was quite easy to modify the code to support Quotations but this is the final thing needed, so that customer can select “Quotation” payment method, and the status is automatically set to “Quote” at “Place Order” event.
If you just use phone.tpl as the payment template, then the status of the placed order (quotation) will be Open. You could run a small script that was run from cron to look at all Open statuses and then if the payment_id matches that of your Quotation, then change the status to a different status with the appropriate email message you want to send (or not).
Alternatively you can use the 'change_order_status' hook to determine when an order is being changed from 'N' to 'O' and then check the payment method there and just update the to_status to the newer status you want. This would be the easiest and most reliable way.
Can anyone tell me how to do this with 4.3.4 version i've made as Zahhar said, but it does not work for me (((
I need to change default order status Open to some other when one of the payment method is selected and order is done by customer. I'm using phone.tpl for this payment method.
You would use the 'change_order_status' PHP hook (I wouldn't use the order_placement_routines).
I don't know your technical abilities, but I can describe how to do this briefly here.
Enable My Changes addon.
Create or edit the file func.php in app/addons/my_changes directory.
Add function like (note this is an example):
function fn_my_changes_change_order_status($&to, $from, &$order_info) {
$payment_ids_to_act_on = array(3, 9, 15); // get these from the actual payment methods. Should see payment_id=xx when editing a payment
$new_status = 'X';
if( !empty($order_info'payment_method']['payment_id']) && in_array($order_info['payment_method']['payment_id'], $payment_ids_to_act_on) )
$to = $new_status;
}
Save the file to your server and load any page (you are checking for syntax or other errors from including this function).
Then create/edit app/addons/my_changes/init.php and have it contain:
I also would like to have the option to change the default order status according to the payment method as offline payment should not have the same behaviour as online ones, is it possible already?
I also would like to have the option to change the default order status according to the payment method as offline payment should not have the same behaviour as online ones, is it possible already?
if you want to set another status for offline payment methods, please open the app/functions/fn.cart.php file and replace:
This really needs to be available from the admin side. And I think any changes like this will break if any update includes the app/functions/fn.cart.php file. Would be nice to have a a future version include this ability from admin.
This could be done by an addon payment method that didn't do anything but collect the info from whatever template you chose. You would simply set the value of the order as an addon setting and then have a simple processor script set $pp_response['order_status'] = Registry::get('addons.my_processor_addon.order_status'); Where the 'order_status' setting would be a selector of all available order statuses. No need to modify the core at all.
Take a couple of hours to put it together and test. This is the niceset solution and gives you a chance to change your mind on order status in the future.
Alternatively, you could use the 'change_order_status' hook and if the $to_status is 'O' and $order_info['payment_id'] is empty, then this would be assumed to be an offline processor (no payment_id) and you would simply adjust the $to_status to whatever you want. This would be done in your my_changes addon or other addon area.
You should avoid making core code changes wherever possible. The system provides many hooks and other methods to let you do so.
That's the nice thing about cs-cart. There are always many ways to skin the cat.