View Single Post
  #1  
Old 04-04-2005, 03:08 PM
 
smitty smitty is offline
 

Member
  
Join Date: Mar 2005
Posts: 27
 

Default HERE is how to change invoice numbering with MYSQL

I was trying to find out how to change the invoice numbering. The data for invoice numbers is stored in your my sql database.

Unforch, all the posts on how to change the invoice numbering said to use phpMyAdmin. It's a great program, but installng it or figuring out how to use it can be as much work as making this change by telnetting in and making the change to mysql that way.

Soooooooo, I saved all my work on how to just telnet in and I'm sharing it with anyone who wants it.

This is how to change invoice numbering very easily. It assumes you know how to telnet into your host. If you don't know, I'm sure there is info in this forum.

BTW, I did this with fake orders during development so as to play it safe. And as always, when monkeying around, backup your mysql database in case something goes wrong.

--------------
Us the telnet program of your choice to connect to your web host. Log in. Once you are successfully logged in, you will access your mysql database via command-line prompts in telnet.

(letters in ALL CAPS below should be substituted with your own user info)

1. get into mysql
at the prompt, enter:

Code:
mysql -h HOSTNAME -u USERNAME -p

the shell will reply with

Code:
Enter password:

enter your password for your mysql database

the prompt will now look like this:

Code:
mysql>

you want to tell it which database to use, so enter the command

Code:
use YOURDATBASENAME;

All you want to do is change the number of the last (highest numbered) order in your system to whatever you want to start the invoice numbers at.
I didn't want them to read 1, 2, 3. I like to have them start at 50000, with the 5 representing 2005. In 2006, I will reset the invoice order to 60000.

So, first, we want to see the orderids already in mysql, so issue the command

Code:
select orderid from xcart_orders;

for me it returned: (your data will probably be different)

Code:
+---------+ | orderid | +---------+ | 1 | | 2 | | 3 | | 4 | | 5 | | 6 | | 7 | | 8 | | 9 | | 10 | +---------+ 10 rows in set (0.00 sec)

This shows me the orderid info stored in the table "xcart_orders." There are 10 orders in the database, with invoices numbered 1 through 10.

Invoice numer 10 is the last one in there, and that's the only one I want to change. So I told mysql to add 50000 to the orderid number, when the orderid number = 10. (This will change order 10 to 50010 and leave the other ones alone.)

the command to do that was:

Code:
update xcart_orders set orderid=orderid+50000 where orderid=10;

Now, if we ask to see the orderid data again,we issue the command:

Code:
select orderid from xcart_orders;
it says:
Code:
+---------+ | orderid | +---------+ | 1 | | 2 | | 3 | | 4 | | 5 | | 6 | | 7 | | 8 | | 9 | | 50010 | +---------+ 10 rows in set (0.00 sec)

So, the next order that is placed will be 50011. Ba bing.

I hope this makes sense and saves someone some time.
__________________
X-Cart version 4.0.12
PHP 5.2.4-2ubuntu5.10
MySQL server 5.0.51a-3ubuntu5.5
MySQL client 5.0.51a
Web server Apache
Operation system Linux
Perl 5.008008
Reply With Quote