Guest Posted July 29, 2003 Share Posted July 29, 2003 Has there been a completed contribution made for this ramdon order number? If so what is it called Link to comment Share on other sites More sharing options...
msheno01 Posted July 30, 2003 Share Posted July 30, 2003 I have installed the contribution with following the steps mentioned in page 1 of this post. For some reason, I am always getting a "0" order number. I have looked at the code, but it seems fine. I am not sure what the problem is. Help Thanks Link to comment Share on other sites More sharing options...
msheno01 Posted July 30, 2003 Share Posted July 30, 2003 I have installed the contribution. But it didn't work, so I reverted to the back up. But it still wont work. I have changed the database to INT(11) and set it to auto inc. but it only generates one order number of "1". Because of this I am getting an error on my checkout page for a duplicate entry in order table, order ID. Please advice Thanks Link to comment Share on other sites More sharing options...
Guest Posted July 30, 2003 Share Posted July 30, 2003 If you have a backup of your database, try restoring it. I had similar issues after adding the code, but after restoring the backup & making the change to the database again, it seems to be working fine. :) Link to comment Share on other sites More sharing options...
msheno01 Posted August 12, 2003 Share Posted August 12, 2003 This is great addition to OSC. I would like to get this to work on my site. I have been trying for several month to get different versions of this to work and finally gave up. I have applied every step that is mentioned here, even tried different random codes but always come up with a duplicate error"". There is no value in the quotes, it's like it is not even seeing ordernum value. When I switched to the backup, I get a "Duplicate error of "214..." number. that number never seems to change. I did change the tables to INT(11) but still getting that number error. Please let me know how to get this addition to work correctly. Is there anything that I missed. Please let me know if you need the code for any page. Thank You Link to comment Share on other sites More sharing options...
Guest Posted August 12, 2003 Share Posted August 12, 2003 Try VARCHAR(11) Link to comment Share on other sites More sharing options...
msheno01 Posted August 13, 2003 Share Posted August 13, 2003 I have tried this command alter table orders change orders_id orders_id varchar( 11 ) not null auto_increment I am getting this error: Incorrect column specifier for column 'orders_id' I can set it to VARCHAR(11) without auto inc. Link to comment Share on other sites More sharing options...
Guest Posted August 14, 2003 Share Posted August 14, 2003 Auto increment means that it increases by one every time a new row (order) is added and only works on integer types (e.g. INT). This thread is about creating random order numbers. This is a different selection method than auto-increment, and they are mutually exclusive. It can be INT(11) auto-increment *or* varchar(11) and made to be random, not both. Which do you want to do? Hth, Matt Link to comment Share on other sites More sharing options...
msheno01 Posted August 14, 2003 Share Posted August 14, 2003 I would like to make the order number random. I have tried with both INT(11) and VARCHAR(11) but it still wont work. The process always gives me a duplicate error of "" for key 1 It is not even reading the ordernum value despite following all the steps precicly. I can post the checkout process.php file and your help would be greatly apprectiated. Thanks Link to comment Share on other sites More sharing options...
Guest Posted August 14, 2003 Share Posted August 14, 2003 Did you run alter table orders change orders_id orders_id varchar( 11 ) not null and verify that the database took it? Hth, Matt Link to comment Share on other sites More sharing options...
MickiCheers Posted September 5, 2003 Share Posted September 5, 2003 I installed this contribution too, and everything "seems" fine. However, when I went to the admin->customers->orders to update the test orders that i made to "delivered" I receive the error " Error: Order does not exist." in the pink highlight at the top of the page. I looked in the orders table on my database and see that the orders do in fact exist in the table with the updated order numbers. Can anyone think of anything that I've missed? See below Orders table: orders_id customers_id customers_name MX0904030 23 Lala Myers AZ0904039 18 Micki Cheers Order status history: orders_status_history_id orders_id orders_status_id 33 MX0904030 1 34 AZ0904039 1 Looks like I have some type of problem with orders_status_history_id attempting to increment. Please advise. Link to comment Share on other sites More sharing options...
Pica Posted September 6, 2003 Share Posted September 6, 2003 I read all the posts in here trying to find an idea/solution for my order numbers... All my offline paperwork (including invoices is based on a clear structure (for me anyway) which includes a reference for : type of document, date, a customer code, a customer's index. Additionaly, invoices have a full index at the end. An example for a "reference" could be : I-030906-ABCD-07-057 This translates as follows : I - stands for Invoice (other letters mean Order, Service, Rma, ...) 03 - year 2003 09 - september 06 - day 6 ABCD - it's a unique customer 4 letter code based on name 07 - means this is the 7th invoice for this customer 057 - this is the 57th invoice (sequential coding // auto_increment) What I would like to do with osC Order numbers would be to catch : - year, month and day - client's 4 letter customer code (from the customers table) I would be willing to drop the customers index (07 here above) if I can use all the rest WITH an auto_increment at the end !!! That would allow me to combine both online AND offline business. Does this make any sense to you ?.... Thanks in advance ! Paulo. Link to comment Share on other sites More sharing options...
MickiCheers Posted September 7, 2003 Share Posted September 7, 2003 i also wanted to mention that the order number is cast to an (int) all over the place in the code. I had to take out most of these occurances before i finally ended up taking the letters out of my random order number. i'm all too sure that this is the cause of at least a few people's problems. Link to comment Share on other sites More sharing options...
fasteddie Posted September 16, 2003 Share Posted September 16, 2003 Yes, I couldn't get this to work when using 2 letters before the order number. I would get Order Does Not Exist in my admin panel. So I changed the code to 10 for the first few digits and it all seems to work now... Change $ordernum line to: $ordernum = '10'.$t1.$r1; Link to comment Share on other sites More sharing options...
Guest Posted October 10, 2003 Share Posted October 10, 2003 I have read all 9 pages - and got some useful tips, but no matter what I do, I ALWAYS get 'ORDER DOES NOT EXIST' error if trying to edit order status etc..... I am using only numbers in my order number, I have changed order_id to VARCHAR in all applicable tables.... Please help me. Link to comment Share on other sites More sharing options...
Guest Posted October 10, 2003 Share Posted October 10, 2003 Further to my above post - I have done a complete new install on a different server, and done the random order number modification only. I did this as I though maybe other mods on my original installation was causing a problem. Anyway, brand new install, made the changes, and still Order does not exist problem. I then changed the tables back to original (INT(11)) and orders table to Auto_increment and went back to edit and now it all functions properly ie: no order exist errors. But of course now, the tables are not set correct to maintain these random numbers...... please help me....and I have been battling with this for about 6 hours now....back and forth....backuping up original, editing, searching for the problem.... Link to comment Share on other sites More sharing options...
Guest Posted October 21, 2003 Share Posted October 21, 2003 Anyone? Link to comment Share on other sites More sharing options...
_pleb Posted October 31, 2003 Share Posted October 31, 2003 I originally couldn't get this working either - like others, orders were not being found. Mine does now work, and follows a similar logic to fasteddie's solution: Yes, I couldn't get this to work when using 2 letters before the order number. I would get Order Does Not Exist in my admin panel. So I changed the code to 10 for the first few digits and it all seems to work now... Change $ordernum line to: $ordernum = '10'.$t1.$r1; Instead of removing $l1 and $l, I just changed the $input array to use the nine singular digits, instead of the 26 letter characters Mine now simply looks like this: $t1 = date("mdy"); srand ((float) microtime() * 10000000); $input = array ("1", "2", "3", "4", "5", "6", "7", "8", "9"); $rand_keys = array_rand ($input, 2); $l1 = $input[$rand_keys[0]]; $l2 = $input[$rand_keys[1]]; $r1 = rand(0,9); $ordernum = $l1.$l2.$t1.$r1; Which generates order numbers like so: 781031038 Hope that helps! Link to comment Share on other sites More sharing options...
_pleb Posted November 4, 2003 Share Posted November 4, 2003 Sigh, I'm stumped - why can't I use a different (more logical) date format? If I use $t1 = date("mdy"); then the orders exist and can be viewed/invoiced etc. If however, I change the date string to ymd, or Ymd, or anything with year at the front, then the order fails to exist - why?! This is really, really bugging me. Link to comment Share on other sites More sharing options...
♥MYC267 Posted November 17, 2003 Share Posted November 17, 2003 I did the same as you pleb and I got it working although there is still room for a duplicate number to be generated. Can we add minutes and seconds in to it? Dan Link to comment Share on other sites More sharing options...
rubygirl Posted March 4, 2004 Share Posted March 4, 2004 did this ever get resolved -have been working with all the comments throughout these posts for several hours with no success - my issue however, similar to some, is that no order # is actually posting - so it appears when a second order is placed that a duplicate entry is trying to post because again no order # is posting.... thoughts? Link to comment Share on other sites More sharing options...
iamcanadian Posted March 10, 2004 Share Posted March 10, 2004 This is what I did to get this working 1. Change orders_id type from INT(11) to VARCHAR(17) in the following tables: orders orders_products orders_products_attributes orders_products_download orders_status_history orders_total Turn Auto_increment OFF in orders table 2. Paste the following script right before this line in checkout_process.php // load the before_process function from the payment modules $t1 = date("mdy"); srand ((float) microtime() * 10000000); $input = array ("1", "2", "3", "4", "5", "6", "7", "8", "9"); $rand_keys = array_rand ($input, 2); $l1 = $input[$rand_keys[0]]; $l2 = $input[$rand_keys[1]]; $r1 = rand(100,999); $ordernum = $l1.$l2.$t1.$r1; 3. Change the following code: $sql_data_array = array('customers_id' => $customer_id, to the following code: $sql_data_array = array('orders_id' => $ordernum, 'customers_id' => $customer_id, 4. Change this Code: $insert_id = tep_db_insert_id(); to the following code: $insert_id = $ordernum; This produces a random order number like 25100202599 If you are having problems editing your orders do the following:: In edit_order.php CHANGE all instances of (int)$oID to $oID I also have the MANUAL ORDER ENTRY CONTRIBUTION installed and had to do the following steps as well: 1. In create_order_process.php after: include(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CREATE_ORDER_PROCESS); ?> <?php ADD: $t1 = date("mdy"); srand ((float) microtime() * 10000000); $input = array ("1", "2", "3", "4", "5", "6", "7", "8", "9"); $rand_keys = array_rand ($input, 2); $l1 = $input[$rand_keys[0]]; $l2 = $input[$rand_keys[1]]; $r1 = rand(100,999); $ordernum = $l1.$l2.$t1.$r1; 2. Change the following code: $sql_data_array = array('customers_id' => $customer_id, to the following code: $sql_data_array = array('orders_id' => $ordernum, 'customers_id' => $customer_id, 3. Change this Code: $insert_id= tep_db_insert_ id(); to the following code: $insert_id = $ordernum; Link to comment Share on other sites More sharing options...
sezcor Posted March 24, 2004 Share Posted March 24, 2004 Hey gus, You have to fix /admin/orders.php as previously suggested: Change: (int)$oID To: (int)$oID And you have to fix /admin/classes/order.php also: Change: (int)$order_id To: $order_id I was having similar problems, but this solved it. Good luck. KS Link to comment Share on other sites More sharing options...
Redlining13 Posted March 21, 2005 Share Posted March 21, 2005 I've read all the posts and the problems that happen in the download.php, editing orders, and viewing order history and status. There is a simple SOLUTION. All the problems happen because the default oscommerce version assumes the 'order_id' is an interger (int). So when all the columns in the table are changed from 'int' to 'varchar', you have to go through the pain of changing the script and renaming varibles ( e.g. (int)$oid to $iod ). And trust me it gets complicated and causes problems in various other pages. Instead: (1) DO NOT include any HYPENS or LETTERS in the random order number, just simple INTEGERS. (2) Change the column 'order_id' in TABLES orders, orders_products, orders_products_attributes, orders_products_download, orders_status_history and orders_total to BIGINT(20). So you DO NOT HAVE TO ALTER ANY SCRIPTS! The column is still considerd an integer. (3) Place whatever algoritham you want to use to generate your order number in checkout_process.php right before: // load the before_process function from the payment modules *** NOTE make sure that the algoritham does NOT have any hypens or letters... only integers. For example: srand ((float) microtime() * 10000000); $r1 = rand(1000,9999); $t1 = date("yzHis"); $ordernum = $t1.$r1; (4) Change the following code in checkout_process.php: $sql_data_array = array('customers_id' => $customer_id, to the following code: $sql_data_array = array('orders_id' => $ordernum, 'customers_id' => $customer_id, (5) Change this Code on the same page: $insert_id = tep_db_insert_id(); to the following code: $insert_id = $ordernum; So, now you get a number like 5781838173280. '5' being the year 2005 (It is NOT '05', b/c as a BIGINT the first '0' is dropped) '78' being the number of the day in the year '18' being the hour (24-hour) '38' is minutes '17' is seconds '3280' random number Now you wont have any problems either in your other pages, and you dont have to alter anything else... very simple. Link to comment Share on other sites More sharing options...
bodek2 Posted April 6, 2005 Share Posted April 6, 2005 also the files 1. account_history.php account_history_info.php chould be corected. ad1. insted of (int)$history['orders_id'] shuld be $history['orders_id'] ad2. istead (int)$HTTP_GET_VARS['order_id'] should be $HTTP_GET_VARS['order_id'] and if you use varchar(11) or varchar(17) insted of the line about 19 if (!isset($HTTP_GET_VARS['order_id']) || (isset($HTTP_GET_VARS['order_id']) && !is_numeric($HTTP_GET_VARS['order_id']))) { should be if (!isset($HTTP_GET_VARS['order_id']) ) { Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.