Feature request: use random order number

Phoca Cart - complex e-commerce extension
mino182
Phoca Professional
Phoca Professional
Posts: 185
Joined: 12 Feb 2015, 13:30

Re: Feature request: use random order number

Post by mino182 »

Jan wrote: 21 Feb 2024, 16:58
there is no problem to add new variable {randomstring}, but the question still remains, how to prevent from possible duplicate?
Jan
{randomstring} could be based on timestamp...

Or something like {randomstring}{id}{randomstring}. And id will be with fixed lenght...

Tags:
keep2000
Phoca Enthusiast
Phoca Enthusiast
Posts: 50
Joined: 14 Nov 2022, 12:04

Re: Feature request: use random order number

Post by keep2000 »

Jan wrote: 21 Feb 2024, 16:58 Hi, the questions:

- how to avoid possible duplicates with random number?
- the ID is still used in e.g. links, etc, so even if there is random number for order number (not order ID), there is still some chance, user can get the ID e.g. in links, etc. :idea:

there is no problem to add new variable {randomstring}, but the question still remains, how to prevent from possible duplicate?

Jan
The second issue isn't a significant problem I think. Of course, heavy users can dig out the information, although some platforms (like VirtueMart) use order number-based tracking URLs.

As for the first issue, VirtueMart uses order ID-based hash/token. This token doesn't directly contain the ID but generates a random unique string based on it. Or it could be based on the timestamp.
Alternatively, there's the plain old method: checking and regenerating until it's not already taken. For a 8-10 characters long alphanumeric string won't be too much conflict:) using numbers and capital letters for a 8 character long string there are 36^8 =2,821,109,907,456 variations if I'm right. For 10 characters it's 3,656,158,440,062,976
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48299
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Feature request: use random order number

Post by Jan »

Hi, added to feature request list:
https://github.com/PhocaCz/PhocaCart/issues/212

Jan
If you find Phoca extensions useful, please support the project
Post Reply