Skip to main content

Change the Order Reference to Number Reference

In order to change the Order Reference to Number Reference you need to extend the order.php class and override generateReference function 

 

You should create a file called order.php in the folder /override/classes/order and paste the above code.

 

<?php
/*
*  RETURN ORDER REFERENCE TO SEQUENTIAL NUMERIC VALUE
*
*/

Class Order extends OrderCore
{
/**
 * Gennerate a unique reference for orders generated with the same cart id
 * This references, is usefull for check payment.
 *
 * @return string
 */
  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);
  }
}

Tags