Gany.akshu Posted November 27, 2012 Share Posted November 27, 2012 (edited) Hi guys, Using new version of Prestashop 1.5.2.0. I would like to change the Order reference ( alphabets ) to alphanumeric value. I tried searching in forums and Seen this forum. Unfortunately it wont work for me. Can any one have solution to change Order reference ( alphabets ) to alphanumeric value in entire application. I mean "AQMKATRQG" to "AK1001" and the increment it to "AK1002" Thanks in advanced. I am in only hope of getting solution from helping hands. Edited November 27, 2012 by Gany.akshu (see edit history) Link to comment Share on other sites More sharing options...
Gany.akshu Posted November 29, 2012 Author Share Posted November 29, 2012 I really in need help. Please someone provide me solution for above topic. . Only becoz of this my website is in hold to release for more than 3 days!!! Link to comment Share on other sites More sharing options...
eddiebarsant Posted December 3, 2012 Share Posted December 3, 2012 Hello, Gany! How are you? We posted a tip on this need on our blog. Access the link below and check. http://brasilweb3.com.br/prestashop-v1-5-referencia-numerica-para-pedidos/ For questions, contact us. Hugs! Link to comment Share on other sites More sharing options...
Gany.akshu Posted December 4, 2012 Author Share Posted December 4, 2012 Thank you for this. If i want ALPHANUMERIC values. I have edited your code as below. " / classes / order / Order.php " return strtoupper (Tools :: passwdGen (9 'ALPHANUMERIC')); And in The file ' / classes / Tools.php " public static function passwdGen ($ length = 8, $ flag = 'ALPHANUMERIC') { switch ($ flag) { case 'NUMERIC': $ str = '0123456789 '; break; case 'NO_NUMERIC': $ str = 'AK'; break; default: $ str = 'abcdefghijkmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; break; } for ($ i = 0, $ passwd =''; $ i <$ length, $ i + +) $ passwd. = Tools :: substr ($ str, mt_rand ( 0, Tools :: strlen ($ str) - 1), 1); return $ passwd; } So that I can get the order reference as only AK(Numberic) values. Please correct me if I am wrong. Link to comment Share on other sites More sharing options...
eddiebarsant Posted December 4, 2012 Share Posted December 4, 2012 Hello! How are you? The default function is eight alphanumeric characters. If you want to change the default function for nine characters and call without passing parameters, so it runs in your default template. Create a new standard, if you want, and enter a prefix or suffix as well understood. You can concatenate your code AK + X sequence of numbers or letters or alphanumeric characters. Hugs! Link to comment Share on other sites More sharing options...
mohamadeffazuan Posted December 5, 2012 Share Posted December 5, 2012 Hello eddiebarsant, Can you explain more detail on how to create a code to add prefix + sequence of number. Currently I'm also in the process to create a prefix for order number. Thank you. Link to comment Share on other sites More sharing options...
Gany.akshu Posted December 7, 2012 Author Share Posted December 7, 2012 Hello eddiebarsant, Can you please explain more in detail or sample code to create a code to add prefix + sequence number. Link to comment Share on other sites More sharing options...
mohsart Posted December 7, 2012 Share Posted December 7, 2012 Ok, this works, kinda. I have HK[numberic string] now, but it's still random, not sequential. /Mats Link to comment Share on other sites More sharing options...
mohamadeffazuan Posted December 8, 2012 Share Posted December 8, 2012 Guys, For order number, I'm using order id instead of reference and it's same as you can see in the Order history. Go to pdf/invoice.tpl (line: 77) and change to this code {l s='#'}{$order_invoice->id_order|string_format:"%06d"} 3 Link to comment Share on other sites More sharing options...
Mrkdd Posted December 8, 2012 Share Posted December 8, 2012 Thanks Mohamadeffazuan, this works fine for me and looks a lot better as the alphanumeric order number. Link to comment Share on other sites More sharing options...
PatJ Posted January 31, 2013 Share Posted January 31, 2013 (edited) Hello, Mohamadeffazuan >> This worked fine for me as well, thank you for sharing this. Edited January 31, 2013 by tecnimodel (see edit history) Link to comment Share on other sites More sharing options...
thinks Posted February 22, 2013 Share Posted February 22, 2013 #9 mohamadeffazuan Thanks for the tip- but please can you also give us the line of script that we are to replace-- just to make sure we're replacing the right line (my line 77 is a <br/> ) Link to comment Share on other sites More sharing options...
mohamadeffazuan Posted February 22, 2013 Share Posted February 22, 2013 thinks, I'm using PS 1.5.1, so it's line 77 or you can find this code, {$order->getUniqReference()} and replace with code that I gave before. Link to comment Share on other sites More sharing options...
manis inspire Posted July 5, 2013 Share Posted July 5, 2013 thinks, I'm using PS 1.5.1, so it's line 77 or you can find this code, {$order->getUniqReference()} and replace with code that I gave before. saya buat kenapa tak jadi ye. saya guna version 1.5.2.0 end result sama je, tetap alphabet yang tonggang langgang tu..huhu. boleh tolong x? Link to comment Share on other sites More sharing options...
Carolim Posted July 8, 2013 Share Posted July 8, 2013 Guys, For order number, I'm using order id instead of reference and it's same as you can see in the Order history. Go to pdf/invoice.tpl (line: 77) and change to this code {l s='#'}{$order_invoice->id_order|string_format:"%06d"} Thanks Mohamadeffazuan, this works Link to comment Share on other sites More sharing options...
mohamadeffazuan Posted July 8, 2013 Share Posted July 8, 2013 saya buat kenapa tak jadi ye. saya guna version 1.5.2.0 end result sama je, tetap alphabet yang tonggang langgang tu..huhu. boleh tolong x? Tolong tunjukkan coding yg anda buat. Link to comment Share on other sites More sharing options...
vekia Posted July 8, 2013 Share Posted July 8, 2013 Tolong tunjukkan coding yg anda buat. we are on english section. please write in english language - respect forum rules. Link to comment Share on other sites More sharing options...
scorpionsworld Posted July 8, 2013 Share Posted July 8, 2013 (edited) To complement this thread. I have created a free module to change (random character) order reference to order_id AND/OR cart_id with optional prefixes. Check out http://www.prestasho...-andor-cart-id/ Edited July 8, 2013 by scorpionsworld (see edit history) Link to comment Share on other sites More sharing options...
totallighting.sk Posted December 20, 2013 Share Posted December 20, 2013 To complement this thread. I have created a free module to change (random character) order reference to order_id AND/OR cart_id with optional prefixes. Check out http://www.prestasho...-andor-cart-id/ Not working under 156 Link to comment Share on other sites More sharing options...
scorpionsworld Posted December 21, 2013 Share Posted December 21, 2013 Not working under 156 Installato su 1.5.6.1 funziona perfettamente. Grazie! "Installed on 1.5.6.1 works perfectly. Thank you!" http://www.prestashop.com/forums/topic/218257-module-change-order-reference-using-order-id-andor-cart-id/page-10?do=findComment&comment=1499737 Link to comment Share on other sites More sharing options...
TechnoSpain Posted February 5, 2014 Share Posted February 5, 2014 http://www.prestashop.com/forums/topic/218257-module-change-order-reference-using-order-id-andor-cart-id/page-10?do=findComment&comment=1499737 Hi Scorpionworld on 1.5.6.2 not works Thanks for your time Regards carlos Link to comment Share on other sites More sharing options...
vekia Posted February 6, 2014 Share Posted February 6, 2014 hwat kind of issues you've got? Link to comment Share on other sites More sharing options...
TechnoSpain Posted February 6, 2014 Share Posted February 6, 2014 Hi, When install received this message Class OrderPayment Override Original 52dec090a6720 does not exist! Error while installing module class Link to comment Share on other sites More sharing options...
pmlvfs Posted May 23, 2014 Share Posted May 23, 2014 Found this, I think this solves everything http://www.prestashop.com/forums/topic/218257-module-change-order-reference-using-order-id-andor-cart-id/ Link to comment Share on other sites More sharing options...
lovemyseo Posted July 28, 2014 Share Posted July 28, 2014 Guys, For order number, I'm using order id instead of reference and it's same as you can see in the Order history. Go to pdf/invoice.tpl (line: 77) and change to this code {l s='#'}{$order_invoice->id_order|string_format:"%06d"} Worked like Charm thanks Link to comment Share on other sites More sharing options...
Richard Hall Posted May 5, 2015 Share Posted May 5, 2015 For anyone who would like to reinstate the default behaviour of PrestaShop v1.4 where orders are assigned an ascending numerical order number prefixed with zeros instead of what would appear to be 9 random letters, I have posted the source code and method in response to someone's question on the StackOverflow website: How to change the order reference to number reference Modifications to the source code to change the numerical order number to include an alphanumeric prefix would not be difficult. 1 Link to comment Share on other sites More sharing options...
sting5 Posted May 11, 2015 Share Posted May 11, 2015 (edited) For anyone who would like to reinstate the default behaviour of PrestaShop v1.4 where orders are assigned an ascending numerical order number prefixed with zeros instead of what would appear to be 9 random letters, I have posted the source code and method in response to someone's question on the StackOverflow website: How to change the order reference to number reference Modifications to the source code to change the numerical order number to include an alphanumeric prefix would not be difficult. A big THANKS Richard! 1.6.0.14 version here - been trying to find a simple solution via .php editing, avoiding modules to install and here is Your post with everything I need! Thanks a bunch! Works like charm! If I see any issues with the code I will surely update this answer. But so far - so good Thanks again! Edited May 12, 2015 by sting5 (see edit history) Link to comment Share on other sites More sharing options...
Xtra Think Posted November 4, 2015 Share Posted November 4, 2015 (edited) HI, for those who still interested in this topic.This is my solution and it works fine for me (PS 1.6) I changed this "generateReference" like this : /** * 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() { $OrderMaxID = Db::getInstance()->getValue(' SELECT MAX(id_order) FROM '._DB_PREFIX_.'orders '); return str_pad((int)$OrderMaxID+1, 9, "0", STR_PAD_LEFT); // return strtoupper(Tools::passwdGen(9, 'NUMERIC')); } NOTA : the order reference will be incremented Edited November 4, 2015 by rachid.antipodes (see edit history) Link to comment Share on other sites More sharing options...
Pietou Posted January 9, 2016 Share Posted January 9, 2016 (edited) Omdat de module Order referentie change niet meer werkt in versie 1..6.1.4 zelf maar wat gemaakt Ga naar classes/order/order.php en zoek op generateReference en vervang de code door deze public static function generateReference(){ $last_id = Db::getInstance()->getValue(' SELECT MAX(id_order) FROM '._DB_PREFIX_.'orders'); return str_pad((int)$last_id + 1, 8, 'NR-000000', STR_PAD_LEFT); } Edited January 9, 2016 by Pietou (see edit history) Link to comment Share on other sites More sharing options...
obewanz Posted July 9, 2016 Share Posted July 9, 2016 (edited) The above solutions are essentially correct, but you REALLY should refrain from modifying any of the core code if you can keep from it. I put all of my mods in a special folder locally after I apply any upgrades to prestashop or my theme engine, then I upload the modifications one by one (after each one is tested). These instructions are for 1.6.x users - ONLY! 1) Create a file named order.php and place this code in that file 2) Next, upload the file to /override/classes/order/order.php 3) Navigate to the /cache folder and delete the file class_index.php (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 be finished now, and your next order will have a reference something like: NR-000101 The second "OPTION" in the code comments returns the order reference number to essentially that of PS 1.5.x - I have also included the appropriate SQL statement in the code comments to set the next order number if needed. PS: I posted a slightly different version of this in another thread, just can't find which one. Edited July 9, 2016 by obewanz (see edit history) 1 Link to comment Share on other sites More sharing options...
grubybarti Posted May 31, 2017 Share Posted May 31, 2017 Do we have any solution for Prestashop 1.7 ? Link to comment Share on other sites More sharing options...
obewanz Posted June 14, 2017 Share Posted June 14, 2017 Do we have any solution for Prestashop 1.7 ? Sorry Grubybarti, I have been unable to install a working version of 1.7 on any of my hosting accounts. I will eventually get around to getting 1.7 working somewhere, so will post a link or the compatible code for that here when it is done. (Please note, PS 1.7 is LOW on my priority list at the moment - I don't mind being on the leading edge of certain technologies, but absolutely refuse to be on the bleeding edge... and with Prestashop's track record of every release breaking something in the prior release - you will absolutely bleed cash if you don't wait for the code to settle down, usually takes about 6 months to a year for these guys.) Link to comment Share on other sites More sharing options...
Recommended Posts