Random order id

Posts: 5
Joined: 06/13/2008

Hello,

I have a funny problem - I need order id to be completely random, because currently, with a known website start date, clients (and competitors) can count number of store orders just by looking at order id. Unfortunately, the id is quite useful for identifying orders (e.g. over the phone), so I don't want to completely remove it (from users). I would like to make it a random, unique, 6-7 digit number - where should I look? Or is too difficult to accomplish?

Thanks, Karel.

Posts: 5
Joined: 06/13/2008

OK, sorry. You really should allow Advanced search even for anonymous visitors:
http://www.ubercart.org/forum/support/755/sanitized_order_numbers

Posts: 5269
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Karel wrote:
You really should allow Advanced search even for anonymous visitors.

Good point. Done. Smiling

Posts: 107
Joined: 08/07/2007
Bug FinderGetting busy with the Ubercode.

What about just using an md5 of the order id? 32 digits is a bit long, but it would appear random.

Posts: 924
Joined: 11/05/2007
Bug FinderFAQ ModeratorGetting busy with the Ubercode.

order_id is a unique key in the DB. However you compute it, you have to guarantee it's unique, otherwise the insert query will fail and the order won't get stored. MD5 is a good hash, but it is just a hash, meaning there's no guarantee that two order_id numbers won't get hashed to the same value. Shouldn't happen often, but when it does you'll never figure out why the order failed!

--

<tr>.

Posts: 34
Joined: 02/04/2008

How's about changing the autoincrement increment in your database. With a little bit of work they could determine the increment, but it'd be a quick sorta-fix.

http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#opti...

Posts: 1293
Joined: 08/14/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.

Ah, that old thread of mine Smiling

Just to keep updated, I ended up making the new order numbers out of time(). I did it once and have left it alone, letting the usual db_next_id() function keep track of those order numbers.

I would love to be able to use alphanumerical combinations, but I suppose that isn't entirely necessary. Perhaps a "Customer order#" that would be more along the lines of a user-friendly number shown only to customers could be generated using a Contrib module, and this value added to forms and order screens. Not a huge deal, though - at least, not for us. Anymore. Smiling

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com