How to change the link to the link to the number

Using the new version of Prestashop 1.5.2.0. I would like to change the Order link (alphabets) to an alphanumeric value. I tried to search the forums and see this forum. Unfortunately this will not work for me.

Can anyone decide to change the link to the order (alphabets) to an alphanumeric value throughout the application.

I mean "AQMKATRQG" on "LD1001" and the increment on "LD1002". I would like to change the Order link (alphabets) to an alphanumeric value. I tried to search the forums and see this forum. Unfortunately this will not work for me.

Can anyone decide to change the link to the order (alphabets) to an alphanumeric value throughout the application.

I mean "AQMKATRQG" on "LD1001", and the increment on "LD1002"

+7
prestashop
source share
3 answers

In PrestaShop 1.6 (tested and confirmed in version 1.6.0.14), you can do this as follows.

  • Copy the file /classes/PaymentModule.php to /override/classes/PaymentModule.php .

  • Edit the file /override/classes/PaymentModule.php as follows.

Lines 337-341 contain a block of code that should look like this:

 if (!result) { PrestaShopLogger::addLog('PaymentModule::validateOrder - Order cannot be created', 3, null, 'Cart', (int)$id_cart, true); throw new PrestaShopException('Can\'t save Order'); } 

Immediately after this code block, insert the following two lines of code:

 $order->reference = str_pad($order->id, 9, '0', STR_PAD_LEFT); $order->update(); 
  1. Delete the /cache/class_index.php file /cache/class_index.php that Prestashop automatically re-creates this file with the new override file.

  2. Any existing entries in the PrestaShop database can be updated to use a numerical link manually using a tool such as phpMyAdmin .

I would suggest that the steps would be very similar if they did not match with PrestaShop v1.5, but at this time I did not test this solution with PrestaShop v1.5. If someone finds that this solution works on v1.5, maybe they can confirm it in the comments. Thanks.

+14
source share

The above solutions are essentially correct, but you REALLY have to refrain from changing any kernel code if you can save it. I put all my mods in a special folder locally after I applied any updates to preashashop or my theme engine, after which I upload the changes one by one (after each test).

These instructions are for 1.6.x users, but MAY work on 1.5.x. I do not have this code for testing.

1) Create a file called order.php and put the code below in this file

2) Then upload the file to /override/classes/order/order.php

3) Go to the / cache folder and delete the class_index.php file (it will be recreated on the next page request)

 <?php /* * RETURN ORDER REFERENCE TO SEQUENTIAL NUMERIC VALUE * * 2016 PrestaShop v1.6.1.x * Override by obewanz * * You can use the following SQL query to change the starting order no if desired * where the number 101 is the next desired order number: * ALTER TABLE `ps_orders` AUTO_INCREMENT = 101 * -------------------------------------------- * OPTION: (ALL NUMERIC) * str_pad((int)$last_id + 1, 9, '000000000', STR_PAD_LEFT); * OPTION SET TO ORIG 1.5.x STYLE REFERENCE NUMBERS: * str_pad((int)$last_id + 1, 6, '000000', STR_PAD_LEFT); */ Class Order extends OrderCore { 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, 'NR-000000', STR_PAD_LEFT); } } 

You should now be finished, and your next order will have a link to something like: NR-000101

The second "OPTION" in the code comments returns the reference order number, essentially for PS 1.5.x - (I had a link to it in the old file.)

I also included the appropriate SQL statement in the code comments to set the next order number, if necessary.

+1
source share

Go to Orders> Invoices to change the next invoice number as you want, and Orders> Warehouse mailings to change the next delivery number.

-one
source share

All Articles