Text Version

There is just one quick step to take, in order to replace the new odd reference number, and that is amending thegenerateReference method of the Order class.
Let’s create an override for it! Create a new file inside override/classes/order and name it Order.php.
Add the usual override code inside:
1
2
3
4
Class Order extends OrderCore
{
 
}
Then, inside it, let’s paste the generateReference method:
1
2
3
4
public static function generateReference()
{
    return strtoupper(Tools::passwdGen(9, 'NO_NUMERIC'));
}
We want to grab the very last order ID, then increase it by one, increase it by one and pad it so all the new references have the same length in terms of characters
1
2
3
4
5
6
7
8
public static function generateReference()
{
    $last_id = Db::getInstance()->getValue('
        SELECT MAX(id_order)
        FROM '._DB_PREFIX_.'orders');
    return str_pad((int)$last_id + 1, 9, '000000000', STR_PAD_LEFT);
 
}