Make order reference equal to order id

Depending on the bank system of your country, it may be sometimes necessary to replace the Prestashop alphabet order reference by number, preferably by order id. There are several free modules suitable for this task. These modules add complexity to the ordering process and may eventually collide with third party payment modules. This may result in occassional difficult to track problems in the ordering process, for example in doubling the real paid amount etc.

In case you experience weird order problems when using an order reference change module, uninstall the module and replace its functionality by the simple code below.

  • open a new file in a clean text editor like notepad (use UTF-8 encoding)
  • copy paste the code into the file
  • save and copy to eshop as /override/classes/order/Order.php
  • clean prestashop cache
 class Order  extends OrderCore

   public function add($autodate = true, $null_values = true)
        if (parent::add($autodate, $null_values)) {

            if($this->id != $this->reference) {
            $this->reference = $this->id;
            return SpecificPrice::deleteByIdCart($this->id_cart);

        return false;

 public static function generateReference()
        $sql = 'SELECT MAX(id_order) FROM '._DB_PREFIX_.'orders WHERE 1';
        $id_order= Db::getInstance()->getValue($sql);
        return (int)$id_order + 1;