In this post, I will guide you to change order reference to number / order ID in Prestashop 1.7. There are four parts showing order refercens, they are: Order history, Guest tracking order, Order invoice and Order confirmation email. You can change one or two or all of them accordion to you needs. To do the change you have to modify some files. Be sure using proper text editers to edit files, like editplus, sublime and Atom, don't use the notepad coming with Windows.
Change order reference to number for the order history page
It is very easy to change order reference to order IDs for the order history page.
1. Open up the /themes/yourtheme/templates/customer/history.tpl file, Replace
1 | s='Order reference' |
with
1 | s='Order ID' |
2. And then change
1 | {$order.details.reference} |
to
1 | {$order.details.id} |
Replace order reference to order IDs for the guest tracking page
If you want to change order reference to order IDS on the guest tracking page to make customers can track their orders by order IDs, you need to modify the following two files:
1. Open up the /themes/yourtheme/templates/customer/guest-login.tpl file.
Change
1 | 'Order reference' |
to
1 | 'Order ID' |
And then change all
1 | order_reference |
to
1 | order_id |
See screenshot:
2. Open up the /controllers/front/GestTrackingController.php. You need to do several changes to the GestTrackingController function.
Repalce the first four
1 | order_reference |
to
1 | order_id |
And then replace this line
1 | $this->order = Order::getByReferenceAndEmail($order_reference, $email); |
With
1 2 | $order = new Order($order_id); $this->order = Order::getByReferenceAndEmail($order->reference, $email); |
Modify order reference to order IDs for invocies.
Open the /pdf/invoice.summary-tab.tpl file, change
1 | 'Order Reference' |
to
1 | 'Order ID' |
And then change
1 | $order->getUniqReference() |
to
1 | $order->id_order |
Change order reference to IDs for the order confirmation email
Edit the /classes/PaymentModule.php file, search for
1 | '{order_name}' => $order->getUniqReference() |
The code appears twice, the one we are looking for is near a Mail::Send function.
Replace it with
1 | '{order_name}' => $order->id |
It is very important to make backups before doing any changes, if something goes wrong, you can just restore files. Don't forget to clear cache to make your changes take effect.
Helpful information, thanks!
It would be useful to make a module that will change the order reference number
Thanks a lot for this tutorial, help a lot.
However, I want to add the two year digits of the invoice_date added infront of the order_id.
e.g. order_id =12 and invoice date = 05-04-2019
So I want to have the following order id in my invoice: 1912
If I just type {$invoice_date}{$id} I will get 05.04.201912
So how can I format the $invoice_date for just this purpose?
Thanks a lot in advance
Dimi Zacharias
Try using this instead {$invoice_date|date_format:"%y"}
After confermation the order, you get confermation page. In the page you see all the order details
Twice order reference with the wrong id JFDFJHFD instead off order id
This must also be changed to order id ! But how to fix
Hello, i changed all files and take a new order.
All cookies are deleted.
it still not work.
PrestaShop
1.7.2.4
thanks.
regards.
1) Transfer me modified files, so I can check your modifications, my email address is helloleemj@gmail.com
2) Upgrade your site, it's recommended to run on at least PrestaShop 1.7.4, because 1.7.2.4 is not that stable.
Hi, are you sure that the last part with /classes/PaymentModule.php file is correct?
Currently it looks like this:
Mail::Send(
(int)$order->id_lang,
'voucher',
Context::getContext()->getTranslator()->trans(
'New voucher for your order %s',
array($order->reference),
'Emails.Subject',
$orderLanguage->locale
According your article it should look like this?
{order_name}' => $order->getUniqReference() to '{order_name}' => $order->id
(int)$order->id_lang,
'voucher',
Context::getContext()->getTranslator()->trans(
'New voucher for your order %s',
array($order->reference),
'Emails.Subject',
$orderLanguage->locale
Thank for pointing the problem out, I've corrected that part, please check.
hello my friend this modified don't work with prestashop 1.7.6.3, please help me