Guest Posted March 17, 2009 Share Posted March 17, 2009 Hi all, So this will hopefully be a really simple question to answer; I am trying to get the order id for the current order from within the code of a payment module that I am creating. Any help will be gratefully accepted. Cheers, Paul Quote Link to comment Share on other sites More sharing options...
Guest Posted March 17, 2009 Share Posted March 17, 2009 Hi All, Ok, solved my problem; I wanted the order number within the payment module code so that I could update the status of orders based on a certain condition. I didn't realise (stupidly) that the "$order_id" variable isn't initialized until after the payment module has added the order to the database. The solution that worked for me: I moved the code that updates the order status in the database to the "after_process()" function in my payment module, and fed it the "$insert_id" variable that is available there. Cheers, Paul Quote Link to comment Share on other sites More sharing options...
webpt Posted April 14, 2009 Share Posted April 14, 2009 hi i need just the same you do you do that , im trying ( but im not a php programmer ) any help will be apreciated !!! Best Regards, Mario VItal Quote Link to comment Share on other sites More sharing options...
Guest Posted April 15, 2009 Share Posted April 15, 2009 Hi, How can I help you Mario, give me a few more details about what you are trying to achieve and I will do the best I can for you. Cheers, Paul Quote Link to comment Share on other sites More sharing options...
webpt Posted April 15, 2009 Share Posted April 15, 2009 (edited) hi Cyburg i believe that from your post that you could get the $order_id from one payment module that you has developing, can u tel me how you do it ? i need the same from one module that i developing but the array $order dont have it . Regards, MV Edited April 15, 2009 by webpt Quote Link to comment Share on other sites More sharing options...
opnsource4all Posted July 9, 2009 Share Posted July 9, 2009 Hi All, Ok, solved my problem; I wanted the order number within the payment module code so that I could update the status of orders based on a certain condition. I didn't realise (stupidly) that the "$order_id" variable isn't initialized until after the payment module has added the order to the database. The solution that worked for me: I moved the code that updates the order status in the database to the "after_process()" function in my payment module, and fed it the "$insert_id" variable that is available there. Cheers, Paul If I understand you correctly, you put the code in from checkout_process into the after_process function of your module. How did you keep it from processing twice ? I think if $$payment->module != $myPaymentModule before the database update in the checkout_process should work. This would allow other methods of payment to access the file with standard functionality. Any advice would be appreciated Quote Link to comment Share on other sites More sharing options...
Guest Posted July 16, 2009 Share Posted July 16, 2009 MY REPLY TO A PM ABOUT THIS TOPIC: Hi, I was working on a new payment module when I had that particular issue, I assume you are also making a custom payment module? When I wrote that particular payment module, I needed to update the record in the database for the order I was working with; I needed to add some data to the order whilst the payment module was being processed at checkout. My first attempts to do this failed because I had placed my code (the code to update the order in database) in the "before_process()" function of my payment module; I scratched my head for ages wondering why I couldn't obtain an order ID to work with. Then I realised that there isn't any order ID available in the "before_process()" function, because at that stage the order hasn't even been inserted into the database, and the order ID is only autogenerated by MySQL when the database insert for the order takes place. In my case the solution was simple, I just moved my custom code to the "after_process()" function in my payment module; at this stage of the process, the ID of the inserted order is available, you can access the value by using the global variable "$insert_id". Here is my "after_process()" function: function after_process() { global $insert_id; // set the order account status flag tep_db_query("update " . TABLE_ORDERS . " set order_on_account = 2 where orders_id = '" . (int)$insert_id . "'"); // set the order status flag tep_db_query("update " . TABLE_ORDERS . " set orders_status = " . MODULE_PAYMENT_PO_ORDER_STATUS_ID . ", last_modified = now() where orders_id = '" . (int)$insert_id . "'"); } Hopefully, you will be able to do your processing in the "after_process()" function of your new payment module; let me know how you get on. I will also post this message to the thread I originally started on this topic, in the hope that it might provide more complete information to anyone else facing the same issue. Cheers, Paul P.S. Apologies for not getting back to you much much sooner Mario; I am always extremely busy at work, and I rarely find time to visit the forum. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.