DenisDT Posted December 2, 2010 Share Posted December 2, 2010 Hello everony!Is somebody interested in being able to do this? I have found a way to do it.Example:Today is 02-12-10, first order -> order number 101202001next order number of the day, 101202002, then 101202003 and so on.The next day, order number simply changes to 101203001, then 101203002 etc etc...The date/time structure is changeable of course. Post it here if you need it and i'll share it! Link to comment Share on other sites More sharing options...
jamieshankland Posted December 4, 2010 Share Posted December 4, 2010 sounds good how did you do it Link to comment Share on other sites More sharing options...
DenisDT Posted December 22, 2010 Author Share Posted December 22, 2010 Well, put this in header.php for a yymmdd001 kind of numbering: $order_res = Db::getInstance()->Execute("SHOW TABLE STATUS LIKE 'ps_orders'"); $order_row = mysql_fetch_assoc($order_res); $order_nextautoid = $order_row['Auto_increment']; mysql_close($order_res); if (substr($order_nextautoid, 0, 6) != date("ymd")) { Db::getInstance()->Execute('ALTER TABLE `'._DB_PREFIX_.'orders` AUTO_INCREMENT = '.intval(date("ymd").'001')); } It checks if the auto_increment has already been changed that day. If no, change it to today and add suffix '001'.If yes, do nothing.Sound good?D. Link to comment Share on other sites More sharing options...
daelew Posted January 3, 2011 Share Posted January 3, 2011 Works Perfect!And looks a whole lot better on confirmations and invoices then f.e. Order nr. 0003Thnx for the tip Link to comment Share on other sites More sharing options...
DenisDT Posted January 3, 2011 Author Share Posted January 3, 2011 You're welcome! I tried finding it further away in the code, but my client didn't have time to wait... So i went for this dirty, dirty hack. Link to comment Share on other sites More sharing options...
vineshkumar Posted January 31, 2011 Share Posted January 31, 2011 The idea is really great...but instead of header.php, it would be great to have it in the respective file...i guess in classes folder..Can you give some idea how to do that??? Link to comment Share on other sites More sharing options...
enagen Posted March 17, 2011 Share Posted March 17, 2011 Nice!!! thanks a lot for this code!vineshkumar u r right, would be much better in classIf someone discovers how to do.... Link to comment Share on other sites More sharing options...
waldemar [pl] Posted March 25, 2011 Share Posted March 25, 2011 Maybe someone could adapt this module for older versions of PS 1.2.4 - 1.3? Please. Link to comment Share on other sites More sharing options...
waldemar [pl] Posted April 4, 2011 Share Posted April 4, 2011 Version for PS 1.2.4 (in attachment).In loyalty module must change in file loyalty.tpl: 'id_order' => 8, to 'id_order' => 10, and voila. ymdnumorderids_for_PS_1.2.4.zip Link to comment Share on other sites More sharing options...
waldemar [pl] Posted April 6, 2011 Share Posted April 6, 2011 No problem , but I have one question (problem).For example:Today date is: 110406auto_increment in ps_orders is: 110404006If someone makes an order. The order number is 110404006, although the today date is different, and auto_increment value should be overridden.Whether this means that retrieves the value id_order Presta earlier than execute the command ALTER TABLE in the module? Link to comment Share on other sites More sharing options...
waldemar [pl] Posted April 6, 2011 Share Posted April 6, 2011 I have (in this moment) in auto_increment in ps_orders table value: 110404006If You do order (in this moment), it will have the number 110404006 - should get 110406001.Next order (second today) will have a number 110406001. Why?sorry for my woodish english. Link to comment Share on other sites More sharing options...
waldemar [pl] Posted April 11, 2011 Share Posted April 11, 2011 I give up. I have no idea why for me it will not work correctly. I do not know why the hook newOrder is executed after confirmation of order.I move a “dirty” hack to order.php - now is ok!. tnx DenisDT and angora! Link to comment Share on other sites More sharing options...
chup Posted April 14, 2011 Share Posted April 14, 2011 hi angora,cool module, glad you share it and nice comment u have in the code Link to comment Share on other sites More sharing options...
salko Posted April 17, 2011 Share Posted April 17, 2011 I have installed this module on Prestashop 1.4. First it looks it will work just fine, but today (17.4.2011) I made a test order and the module generated order number 110412001, which corresponds to the first order on date 12.4.2011. Why the order number is not 110417001? Link to comment Share on other sites More sharing options...
chup Posted April 18, 2011 Share Posted April 18, 2011 hi angorai think i found a small bug alsoit seem to me the date will not update itself for the 1st order of the day, but only update when the second order is made.is this suppose to be normal? Link to comment Share on other sites More sharing options...
chup Posted April 18, 2011 Share Posted April 18, 2011 here is a screenshot of the problemhttp://www.yaoming.sg/download/presta/screen_110418_2.jpgi modify the running number of the code also Db::getInstance()->Execute('ALTER TABLE `'. _DB_PREFIX_ .'orders` AUTO_INCREMENT = '. intval(date("ymd").'1982') ); Link to comment Share on other sites More sharing options...
waldemar [pl] Posted April 18, 2011 Share Posted April 18, 2011 edit: sorry, bad idea... deleted post Link to comment Share on other sites More sharing options...
chup Posted April 19, 2011 Share Posted April 19, 2011 hi angora,your coding is actually working fine, except for the part that the 1st invoice of the day will not be "reset". you get what i mean? i think it has something to do with caches or something. the 2nd invoice of the day onward will work fine with the update date infront of the invoice number. Link to comment Share on other sites More sharing options...
salko Posted June 14, 2011 Share Posted June 14, 2011 hi angora,your coding is actually working fine, except for the part that the 1st invoice of the day will not be "reset". you get what i mean? i think it has something to do with caches or something. the 2nd invoice of the day onward will work fine with the update date infront of the invoice number. I have exactly the same problem, only the first order of the day has a wrong number (it is the next number of order from previous day) ... did you find solution for it? Link to comment Share on other sites More sharing options...
guest* Posted June 19, 2011 Share Posted June 19, 2011 hi angora,your coding is actually working fine, except for the part that the 1st invoice of the day will not be "reset". you get what i mean? i think it has something to do with caches or something. the 2nd invoice of the day onward will work fine with the update date infront of the invoice number. Me too. Any fix for the invoices ? All my invoices are writing Invoice #0, not only the first, but all of the whole day. Link to comment Share on other sites More sharing options...
waldemar [pl] Posted June 19, 2011 Share Posted June 19, 2011 Problem is with hook.Solution is uninstall the module and move dirty hack in order.php under function: if (!$cart->checkQuantities()) { $step = 0; $errors[] = Tools::displayError('An item in your cart is no longer available, you cannot proceed with your order'); } should look like this: if (!$cart->checkQuantities()) { $step = 0; $errors[] = Tools::displayError('An item in your cart is no longer available, you cannot proceed with your order'); } /* Number of order */ $order_res = Db::getInstance()->Execute("SHOW TABLE STATUS LIKE '"._DB_PREFIX_."orders'"); $order_row = mysql_fetch_assoc($order_res); $order_nextautoid = $order_row['Auto_increment']; mysql_close($order_res); if (substr($order_nextautoid, 0, 6) != date("ymd")) { Db::getInstance()->Execute('ALTER TABLE `'._DB_PREFIX_ .'orders` AUTO_INCREMENT = '.intval(date("ymd").'001')); } ...and voila. Link to comment Share on other sites More sharing options...
waldemar [pl] Posted June 19, 2011 Share Posted June 19, 2011 Yes, I have very old PS 1.2.5. HookNewOrder not working correctly in PS 1.2.4 and 1.2.5. (module code is executed after the approval of the order and first of the day have wrong number).Dirty hack can be placed after line ~15 order.php file(PS 1.2.5) $errors = array(); /* here */ - it will work. Link to comment Share on other sites More sharing options...
guest* Posted June 20, 2011 Share Posted June 20, 2011 I'm curious to learn why hookNewOrder is working fine for some, but not all, v1.4+ shopsbut no "fix" is forthcoming (from me, at least) because for me it's working as intended. It's ok and valid, but as it's not working for me and although I have deinstalled it on BO and also deleted the module on BO, all new orders are coming with the order format 11-mm-dd-nr.How to reset the DB ? I just tried by deleting of all orders to begin from zero, but this didn't solved it. Which table I have to put zero, so that counter begans to count from zero (I'm not in production but going by end of this week). Link to comment Share on other sites More sharing options...
guest* Posted June 20, 2011 Share Posted June 20, 2011 deleted - double post Link to comment Share on other sites More sharing options...
guest* Posted June 21, 2011 Share Posted June 21, 2011 Sorry I'm an user, what should exactly I type ? I'm not an IT-profecient. My tables are all original presta, so with ps_xxx Link to comment Share on other sites More sharing options...
guest* Posted June 21, 2011 Share Posted June 21, 2011 I solved it without SQL query and changed the value in the field manually to 1.Thxs. Link to comment Share on other sites More sharing options...
szepnik Posted March 26, 2012 Share Posted March 26, 2012 Any how fix it in 1.4.6.2 ? Link to comment Share on other sites More sharing options...
NPeti Posted April 14, 2012 Share Posted April 14, 2012 1.4.7.3 Test: Ok OrderController.php edit original: /* If some products have disappear */ if (!self::$cart->checkQuantities()) { $this->step = 0; $this->errors[] = Tools::displayError('An item in your cart is no longer available for this quantity, you cannot proceed with your order.'); } under paste: /* Number of order */ $order_res = Db::getInstance()->Execute("SHOW TABLE STATUS LIKE '"._DB_PREFIX_."orders'"); $order_row = mysql_fetch_assoc($order_res); $order_nextautoid = $order_row['Auto_increment']; mysql_close($order_res); if (substr($order_nextautoid, 0, 6) != date("ymd")) { Db::getInstance()->Execute('ALTER TABLE `'._DB_PREFIX_ .'orders` AUTO_INCREMENT = '.intval(date("ymd").'001')); } Link to comment Share on other sites More sharing options...
waldemar [pl] Posted July 5, 2012 Share Posted July 5, 2012 On OVH servers must change the line of mysql_close($order_res); on mysql_close(); Link to comment Share on other sites More sharing options...
Zoomby Posted July 24, 2012 Share Posted July 24, 2012 is this working for ps 1.4.8.2 ? Link to comment Share on other sites More sharing options...
peanut Posted December 20, 2012 Share Posted December 20, 2012 (edited) For those who might be a little confused on how to make this work, I did the following for my PS 1.4.7.3 so you may follow the same if you'd like. First: Download the module from the post below from page 1. ' timestamp='1301931525' post='522055']Version for PS 1.2.4 (in attachment). In loyalty module must change in file loyalty.tpl: 'id_order' => 8, to 'id_order' => 10, and voila. Then make the following changes to your ordercontroller.php file under the controller folder. 1.4.7.3 Test: Ok OrderController.php edit original: /* If some products have disappear */ if (!self::$cart->checkQuantities()) { $this->step = 0; $this->errors[] = Tools::displayError('An item in your cart is no longer available for this quantity, you cannot proceed with your order.'); } under paste: /* Number of order */ $order_res = Db::getInstance()->Execute("SHOW TABLE STATUS LIKE '"._DB_PREFIX_."orders'"); $order_row = mysql_fetch_assoc($order_res); $order_nextautoid = $order_row['Auto_increment']; mysql_close($order_res); if (substr($order_nextautoid, 0, 6) != date("ymd")) { Db::getInstance()->Execute('ALTER TABLE `'._DB_PREFIX_ .'orders` AUTO_INCREMENT = '.intval(date("ymd").'001')); } Make sure your modules permissions are set to 777 recursively. This should work now. Make test orders to confirm. Edited December 20, 2012 by peanut (see edit history) Link to comment Share on other sites More sharing options...
peanut Posted December 20, 2012 Share Posted December 20, 2012 This module would've been perfect if the order number could match the invoice number and the delivery slip number. Does anyone know how we can link them together? Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now