Jump to content

Prestashop 1.7 - Order.php override


Fires04

Recommended Posts

Hi, I really want change order reference to numeric. (TEXT order reference is really difficult  to say via phone to customers). Normaly I do it by override order class by change getOrderReference method.

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);
}

but if I create order.php in  ./overrides/class/order/ nothing happends. I try add hardcoded die() in generateReference method but it do not works.  It looks like prestashop do not use this override class. I check BO and overrides are on. Where could be problem ? 

 

thanks for advice, and have a nice day guys.

Link to comment
Share on other sites

Just now, Fires04 said:

Hi, I really want change order reference to numeric. (TEXT order reference is really difficult  to say via phone to customers). Normaly I do it by override order class by change getOrderReference method.


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);
}

but if I create order.php in  ./overrides/class/order/ nothing happends. I try add hardcoded die() in generateReference method but it do not works.  It looks like prestashop do not use this override class. I check BO and overrides are on. Where could be problem ? 

 

thanks for advice, and have a nice day guys.

 

Have you removed /app/cache/prod/class_index.php?

Link to comment
Share on other sites

  • 3 months later...
  • 2 years later...

Guys, I had the same issue and found out which was the cause. On PrestaShop install (v.1.7.6.7 in my case) there was only the /override/classes directory.

So, it was trying to copy a file to a directory that does not exist (/override/classes/order).

My fix:
 

public function install()
{
    $order_override_directory = _PS_OVERRIDE_DIR_ . 'classes/order';

    if (!is_dir($order_override_directory)) {
        mkdir($order_override_directory, 0755, true);
        copy(_PS_MODULE_DIR_ . $this->name . '/index.php', $order_override_directory . '/index.php');
    }

    return parent::install();
}


Regards ✌🇬🇷🛠🇳🇱

Edited by tapanda.gr
Typo (see edit history)
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...