devilgrins Posted March 10, 2007 Share Posted March 10, 2007 i would like to call the command to get the last or should i say.. newly create order_id... basically i want to know how would i grab the info so i can call on a command to popup window of the last newly create order.. <td><div style="float:left"><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_HISTORY, tep_get_all_get_params(array('order_id')), 'SSL') . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a></div><div style=float:right>'; ?><a href="java script:popupPrintReceipt('<?php echo tep_href_link(FILENAME_PRINT_MY_INVOICE, tep_get_all_get_params(array('order_id')) . 'order_id=' . $HTTP_GET_VARS['order_id'], 'SSL'); ?>')"><?php echo tep_image_button('button_print_order.gif', IMAGE_BUTTON_PRINT_ORDER) . '</a>'; ?></div></td> this is ... the code.. which i do have working though it brings up all the order id details screen.. i would like to call only the last newly create order.. how would i go about doing this... i gather i would have to call on a query to check and grab the newly create order id number right??? but i am unsure how too... can someone assist plllllease :blink: Link to comment Share on other sites More sharing options...
Guest Posted March 11, 2007 Share Posted March 11, 2007 if you have an orders editor or a script that creates the orders, typically there is an action swtich that processes new orders. There should be something like $orders_id = tep_db_insert_id(); The tep_db_insert_id will return back what you need. You should only use it when you create an order and not when you browse. If you browse you need to determine the orders id. You could get the last entered by including with the sql query "order by orders_id desc limit 1" and the query will return back the last one. Link to comment Share on other sites More sharing options...
devilgrins Posted March 11, 2007 Author Share Posted March 11, 2007 if you have an orders editor or a script that creates the orders, typically there is an action swtich that processes new orders. There should be something like $orders_id = tep_db_insert_id(); The tep_db_insert_id will return back what you need. You should only use it when you create an order and not when you browse. If you browse you need to determine the orders id. You could get the last entered by including with the sql query "order by orders_id desc limit 1" and the query will return back the last one. :) i think i am alittle over my head.. how would i call this command .. the print order will be in my checkout_success.php where the customer will have a opportunity to print out the order they just have made.. the code i wrote does work, though it brings to the order page not the newly create order they have just made.. which is where i am up too.. how would this code look like that i would possibly need to enter? thanks for responding enigma1!!! Link to comment Share on other sites More sharing options...
Guest Posted March 11, 2007 Share Posted March 11, 2007 :) i think i am alittle over my head.. how would i call this command .. the print order will be in my checkout_success.php where the customer will have a opportunity to print out the order they just have made.. the code i wrote does work, though it brings to the order page not the newly create order they have just made.. which is where i am up too.. how would this code look like that i would possibly need to enter? thanks for responding enigma1!!! this is already available. If you look the catalog\checkout_success.php you have $orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where customers_id = '" . (int)$customer_id . "' order by date_purchased desc limit 1"); $orders = tep_db_fetch_array($orders_query); Ok now just to make sure you get the last order (eliminating the date purchased thing), change the code to $orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where customers_id = '" . (int)$customer_id . "' order by orders_id desc limit 1"); $orders = tep_db_fetch_array($orders_query); that will give you the result from the database for the last order. $orders['orders_id'] element has this id you're looking for. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.