Background:
I am creating a service booking website. Each order needs to have a unique order number. I have chosen 16 digits because that's what the previous software used.
Questions
I am not sure if there is any benefit to putting data into the order number or if it should just be a purely random string.
If it is just a random string then its only purpose is to act as an ID. If that is the case, then why not just use an incremental ID? Other then to obfuscate the number of orders we have generated to the end user I can't think of a good reason.
If it is a good idea to put data into the string, what kind of data should I include? Probably the date of the order, but other then that I don't know.
I am currently generating a purely random 16 digit string like this.
public function generateOrderNumber()
{
$time = time(); // Time (CET) to hash
$token = md5($time); // Hash stored in variable
return str_shuffle(substr($token, 0, 16)); // Hash shortened to 5 chars and randomised
}
However I am not sure if this is good enough for production.