Jump to content
Daresh

[Free Module] Numeric Order Reference

Recommended Posts

Many shop owners don't like the default random string order reference, but changing it to order ID reveals the number of orders to customers.

 

This module changes the order reference tu numeric and let's you choose between a random number and order ID, you can also add custom prefix and choose to have leading zeros.

 

post-653890-0-53248900-1456658636_thumb.png

 

post-653890-0-31925600-1460916559_thumb.png

 

Module works for Prestashop 1.5, 1.6, 1.7

 

I am sharing this module for free on my most common improvements subscription list on http://greenmousestudio.com/ or below.

 

gmnumeric.zip

 

Update 16.08.2016

gmnumeric_v_1_2_0.zip

 

A few notes in case this module does not work for you and you need to uninstall it:

- this module overrides generateReference() function from the Order class, sometimes (I don't know why) Prestashop leaves the overriden files after uninstall, so check the "overrides/classes/Order.php" and remove the generateReference() function or delete the whole file if there is nothing else in it.

Edited by Daresh (see edit history)
  • Like 11
  • Thanks 1

Share this post


Link to post
Share on other sites

Thank you! Its very useful when some one call and pronunciation the numbers not those weird characters =)

  • Like 1

Share this post


Link to post
Share on other sites

Daresh - maybe you can help me. 

After instalation we can choose random number or ID of the order...But nothing happens...

 

As you can see on the attached screenshot:

1671 - order without your module

1672 - order without your module

1673 - order with your module. Random number 

1673 - order with your module. ID of the order...

 

Presta 1.6.1.4. 

 

post-989321-0-67316500-1456487651_thumb.jpg

Share this post


Link to post
Share on other sites

Maybe you have overrides turned off in your shop? (Advanced -> Performance)

  • Like 2

Share this post


Link to post
Share on other sites

Yea. That's it. :) 

Thank you very much.

Everything works great. 

Share this post


Link to post
Share on other sites

thank you very much.

it would be great if you could add some possibilities like in another module (with that some people have problems)

in the other module you can set ...

http://www.bilder-upload.eu/show.php?file=052209-1456595961.jpg

for example that allow to change from 000000008 -> 8 or 0008

or you can make ory8

Edited by nvpl (see edit history)

Share this post


Link to post
Share on other sites

Thanks for your suggestion, which of these settings would be most important for you?

Share this post


Link to post
Share on other sites

for me it would be enough to erase the zeros and can add a word or something before the order number :)

Share this post


Link to post
Share on other sites

Thank you for your suggestions, as I really want to keep my modules clean and simple. I have updated the module with the prefix and trailing zeros options. Please test and let me know if that's what you wanted.

Share this post


Link to post
Share on other sites

brilliant, thank you very much, that works great and no problems with the mails to admin like in the other module.

Vekia, add that to the free modules if Daresh allow :-)

dzięki

 

it works at 1.6.1.2

at 1.6.1.4 it makes changes but there are only changes in "losowe numery" or "order ID"

I choosed order ID and without zeros and add a prefix but it show 000000412

at the other webshop with 1.6.1.2 everything is working fine

 

OK, I've reinstalled that module

Now at both shops everything is great :-)

thanks once again

Edited by nvpl (see edit history)
  • Like 1

Share this post


Link to post
Share on other sites

Thank you alot for this, it was so annoying to have customers spell that random letters.

  • Like 1

Share this post


Link to post
Share on other sites

A small update - there was a spelling error, the module adds "leading" not "trailing" zeros. No changes in functionality.

Share this post


Link to post
Share on other sites

Hi Daresh!

 

Thanks a lot very useful.

 

Regards

MacRoy

Share this post


Link to post
Share on other sites

Hi Daresh!

 

I got this error after installation of you`re module on Prestashop 1.6.1.5

 

 

/* * module: gmnumeric * date: 2016-04-17 22:29:28 * version: 1.1.0 */ public static function generateReference() { $isRandom = Configuration::get('GMNUMERIC_RANDOM'); $prefix = Configuration::get('GMNUMERIC_PREFIX'); if ($isRandom) { $reference = Tools::passwdGen(9, 'NUMERIC'); } else { $query = 'SELECT `AUTO_INCREMENT` FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = \''._DB_NAME_.'\' AND TABLE_NAME = \''._DB_PREFIX_.'orders\''; $nextOrderId = (int) Db::getInstance()->getValue($query); $zeros = Configuration::get('GMNUMERIC_ZEROS'); if ($zeros == 'on') { $reference = sprintf('%09d', $nextOrderId); } else { $reference = $nextOrderId; } } return $prefix.$reference; }

 

 

And it`s impossible to add a product to the cart.

 

Do you have a fix for that?

 

Regards

MacRoy

Share this post


Link to post
Share on other sites

Just tested on 1.6.1.5 and everything worked fine. I also see that in 1.6.1.5 there was no change in the original function from the Order class, that this module overrides.

 

Maybe you already have some overrides for the Order class?

Share this post


Link to post
Share on other sites

Hi Daesh!

 

One important thing that I have not wrote in my previous post was that, after I changed to custom ID instead of random numbers. Then came this error up.Do you hav any tip for this?

 

I use One Page Checkout PrestaShop v2.1.6 but it is impossible to place a order now after that change!

 

I have even tried to disabled module and even uninstalled it, but the error message still visible all the time and as I said I can not place an order.

 

I have naturally emptied the cache and forced compilation without results!

 

Here is the error message from the cart:

 

 

Impossible to add the product to the cart.

 

textStatus: 'parsererror'

errorThrown: 'SyntaxError: JSON Parse error: Unrecognized token '/''

responseText:

    /*

    * module: gmnumeric

    * date: 2016-04-17 22:29:28

    * version: 1.1.0

    */

    public static function generateReference()

    {

        $isRandom = Configuration::get('GMNUMERIC_RANDOM');

        $prefix = Configuration::get('GMNUMERIC_PREFIX');

        if ($isRandom) {

            $reference = Tools::passwdGen(9, 'NUMERIC');

        } else {

            $query = 'SELECT `AUTO_INCREMENT`

                     FROM INFORMATION_SCHEMA.TABLES

                 WHERE TABLE_SCHEMA = \''._DB_NAME_.'\'

                 AND TABLE_NAME = \''._DB_PREFIX_.'orders\'';

            $nextOrderId = (int) Db::getInstance()->getValue($query);

            $zeros = Configuration::get('GMNUMERIC_ZEROS');

            if ($zeros == 'on') {

                $reference = sprintf('%09d', $nextOrderId);

            } else {

                $reference = $nextOrderId;

            }

        }

        return $prefix.$reference;

    }

 

{"products":[{"id":3,"link":"http:\/\/www.test.se\/casual-dresses\/3-moenstrad-kjol-7300000365455.html#\/storlek-s\/farg-orange","quantity":1,"image":"https:\/\/www.test.se\/8-home_default\/moenstrad-kjol.jpg","image_cart":"https:\/\/www.test.se\/8-cart_default\/moenstrad-kjol.jpg","priceByLine":"249 Kronor","name":"M\u00f6nstrad kjol","price":"249 Kronor","price_float":199,"idCombination":13,"idAddressDelivery":0,"is_gift":false,"hasAttributes":true,"attributes":"S, Orange","hasCustomizedDatas":false,"customizedDatas":[]}],"discounts":[],"shippingCost":"29 Kronor","shippingCostFloat":29,"taxCost":"56 Kronor","wrappingCost":"0 Kronor","nbTotalProducts":1,"total":"278 Kronor","productTotal":"249 Kronor","freeShipping":"251 Kronor","freeShippingFloat":251,"free_ship":false,"isVirtualCart":0,"hasError":false,"crossSelling":false}

 

 

 

What should I do to fix this?

 

Regards

MacRoy

Edited by MacRoy (see edit history)

Share this post


Link to post
Share on other sites

Maybe that override was not removed properly when you deleted the module. Check in override/classes/order/Order.php for generateReference() function.

  • Like 1

Share this post


Link to post
Share on other sites

Hi Daesh!

 

You are quite right, it was still there. Now I removed it and now it works again. Thanks for the tip!

 

Best regards

MacRoy

Share this post


Link to post
Share on other sites

This may be something related to the database, I am getting the autoincrement value for the order table, this query may not work on every server, but the weird thing is that your shop didn't remove the override when you uninstalled the module.

Share this post


Link to post
Share on other sites
Hi.

With this module I could change the order ID?

I have two stores and both wear a slip module of the same bank, the problem is that when it coincides two applications with the same number using slip, error.

The search docket ID and I need to put a prefix numerido this ID to not match.

 

Today looks like this: in 1410 the two stores.

I need you to stay in one of the shops like this: 90001410

Share this post


Link to post
Share on other sites

No, this module does not change order ID, it changes order reference, order ID is a integer number, so it would be much better to operate on order reference with your bank slips, rather than order IDs.

Share this post


Link to post
Share on other sites
Ok, thanks for the reply.

I would like to develop a module to enter this prefix in order ID?

What would be the value to it?

You can send n'e-mail: junior@kitsunestudio.com.br

 

Thank you.

Share this post


Link to post
Share on other sites

The solution to your problem would not be a module, but a change in the orders table structure, so that autoincrement value is 90000000.

Share this post


Link to post
Share on other sites

The solution to your problem would not be a module, but a change in the orders table structure, so that autoincrement value is 90000000.

 

Thanks for the answer.
But I think if I change the auto_increment ps_orders the table to 9000000 will not have future problems?
 
Today my last ID is 1414 to 9000000 can change?
 
ALTER TABLE 'ps_orders' AUTO_INCREMENT = 9000000;

Share this post


Link to post
Share on other sites

Of course it will cause problems, but only after 999999 orders, so you can add one more zero to make it nearly 10 million orders, if think this is quite a large number :)

Share this post


Link to post
Share on other sites
Hi Dev.

 

Thanks for share this awesome module with us.

 

I noticed that at the install process of module, the size of field "reference" in the table "orders" is changed to 32 characters.

 

Notwithstanding, a change to the field "reference" in the table "payment_order" is needed to reflect the same size.

 

Can you adjust this in the next versions?

Share this post


Link to post
Share on other sites

Hi, module works fine, but when i use DotPay (official Polish payment module) it shows me Order ID like in the photo:

eg. #2 

And random number is in parentheses.

 

Do you now how to hide ID in this place? 

 

pay.png

Share this post


Link to post
Share on other sites

You would need to find a code in the DotPay module that passes this data to DotPay. It looks like it passes order Id and reference, we want it only to by the reference.

Share this post


Link to post
Share on other sites

Hello there,

a while ago I installed your module and it works perfectly for PS1.6.1.5.

But I have this little issue, is it possible to change the number of leading zeros?
We are using MoneyS3 and it has order ID restricted to 10 characters. Your module adds 8 zeros.

The format of my order ID must be XXXXX0001 - XXXXX9999.

 

I dont want to mess with your code but can you tell me where it can be changed?

 

Thank you very much

 

Jan Vykoupil

Share this post


Link to post
Share on other sites

In your shop's override/classes/Order/Order.php in function generateReference() there is sprintf('%09d', $nextOrderId); it makes the order reference 9 characters long, so you can mess with it, you have preview in the module.

  • Like 1

Share this post


Link to post
Share on other sites

Hi Daresh,

 

Thank you very much for great module !

I installed it and it seems to work. New order doesn't have random numer like LLIRFVSPN, but has number 8.

I would like to start this autoincrement order number not from 0 or low value as it is now, but from for example 123.

Could you please write is it possible and what and where I should change ?

 

Thank you in advance!

 

Share this post


Link to post
Share on other sites

Thanks!

 

You should check in your database, in the ps_orders table properties, for the current auto increment value, and make it a larger number.

Share this post


Link to post
Share on other sites

Dzięki za info.

Szukałem i niestety we właściwościach tabeli ps_orders nie znalazłem wartości, która jest używana jako aktualna dla numeru zamówienia.

Próbowałem dla wiersza id_order wyłączyć zaznaczenie przy opcji Auto_Increment oraz zmienić wartość w polu Default z None na "As defined" z wpisanym numerem, ale nie działa, a nawet nie chce się zapisać :)

 

Czy mógłbyś zrobić jakiegoś screena i zaznaczyć gdzie dokładnie mam zmienić?

Z góry dziękuję :)

Edited by TTY35 (see edit history)

Share this post


Link to post
Share on other sites

Sorry, I missed info that this thread is part of English forum :)

It works as should, thank you very much.

  • Like 1

Share this post


Link to post
Share on other sites

This works very good! I just install it as usual and its already ready to go! very easy to install and works pretty fine!

  • Like 1

Share this post


Link to post
Share on other sites

Could be very interesting if you can add the reference nbr option  also.

For use is very important that nbr.

But work marvelous.

Thanks a lot

Share this post


Link to post
Share on other sites

Could be very interesting if you can add the reference nbr option  also.

For use is very important that nbr.

But work marvelous.

Thanks a lot

I'm happy that it works for you, but not sure what do you mean by "reference nbr"... Some example?

Share this post


Link to post
Share on other sites

Hi,

 

How do I install it? I couldn't find any manual in a zip file.

 

Thanks

 

 

 

Ps: Ok, I just installed it like any other module and it works fine!!!

Edited by grz3chu (see edit history)

Share this post


Link to post
Share on other sites
Hello, I tried your module on Prestashop version 1.6.1.7

 

I chose reference format: Order ID

 

And each order is 15 ...

 

Without prefix 0000015

With prefix OR0000015

without leading zero 15

 

I tried about 20 orders with different combinations, but it is still only reference 15

 

Please help me :(

Share this post


Link to post
Share on other sites
yes in preview panel in the mode

but also in order mail

and in orders (admin interface)

 

//edit

 


Now that I have turned on your module I can not complete the order.

 

When your module is deactivated, the order will take place as well.

 

HTTP ERROR 500:


Edited by SEID (see edit history)

Share this post


Link to post
Share on other sites

Maybe you have something else installed there that is causing some conflict.

  • Like 1

Share this post


Link to post
Share on other sites
about payments I do not installed any module.

 

anyway thanks

Share this post


Link to post
Share on other sites

Bonjour

Google translate - Prestashop  1.6.1.10

*****************************

I removed version 1.0.0 and installed version 1.2.0.2 of the module and it no longer works

what should I do ? thank you

****************************

J'ai supprimé la version 1.0.0 et j'ai installé la version 1.2.0.2 du module et cela ne fonctionne plus

que dois-je faire ?

merci

 

 

I removed version 1.0.0 and installed version 1.2.0.2 of the module and it no longer works what should I do ? thank you

post-420317-0-33170500-1483462081_thumb.png

Edited by leludo54 (see edit history)

Share this post


Link to post
Share on other sites

Maybe the uninstall was not completely successfull, it sometimes happens, the module is uninstalled but override files are still there, try to uninstall the module once again and also delete Order.php from your overrides/classes folder, and then reinstall the module.

Share this post


Link to post
Share on other sites

Hello

I uninstalled the module and I deleted the file order.php
I made a new installation of the module but I still have text and not numbers!
 
Would you have a solution?
 
Merci

Share this post


Link to post
Share on other sites

Hard to tell, it works fine on my 1.6.1.10 version. You have disable all overrides set to NO?

Share this post


Link to post
Share on other sites

Good evening By setting "no" on override, it works. Thank you

Good evening By setting "over" on override, it works. Thank you

Share this post


Link to post
Share on other sites

Just checked and this module works fine for Prestashop 1.7.

Share this post


Link to post
Share on other sites

Dear Daresh,

i am testing the Module, which seems to be very perfect for me   :D  

Maybe you can give me an short idea, if i can change the order number to 5 or 6 digits only  (e.g. 12345) ?

 

The thing is, that we will use "JTL Wawi" to overtake the orders and we have to go on with the order numbers from our present shop.

 

thank you

Share this post


Link to post
Share on other sites

Set the order reference to order ID, and the autoincrement value for the order ID in the database orders table to 10000, and you should have 5 digits for some time...

Share this post


Link to post
Share on other sites

Hello, thank you for fast reply.

I have the table  _orders

 

 

id_order int(11)   UNSIGNED Nein   auto_increment

 

 

but where to set the autoincrement?  If i set standard for this, the shop only shows  "order number" 3  (as it is the 3rd order in the new shop, this is shown correct).   Also ID is 3.

 

But i did not get the 15xxx  as order number.

Edited by DRMasterChief (see edit history)

Share this post


Link to post
Share on other sites

In the table Operations tab (if you're using phpmyadmin)

Share this post


Link to post
Share on other sites

Sorry, i think it was defined wrong by me.

We will use the "random numbers", but not a number below 15000  (but i think this is not possible easily??)  AND this random number should only have 5 or 6 digits. 

 

>> so we have to limit the order number to 5 or 6 digits, but how?

 

then we can use the random function from your module.

 

thank you

Edited by DRMasterChief (see edit history)

Share this post


Link to post
Share on other sites

In the override/classes/Order.php of your shop change the "9" to the length you want the reference to be:

$restLength = 9 - $prefixLength;
  • Like 1

Share this post


Link to post
Share on other sites

It  works great 1.6.16 thank you soo much. It is more easy to notice for customers an us. 

Share this post


Link to post
Share on other sites

I'm sorry, but this module don't working on my 1.7.2.1 Prestashop

 

Modul installed, settings is working but in preview generated non numeric order number, but order reference.

 

What I did wrong?

Share this post


Link to post
Share on other sites

Thanks for the great module, working fine in Prestashop 1.6.1.17.

One remark only: the config.xml still contains version info 1.1.0, I have changed my copy to 1.2.0 to show the correct info in the modules section of my shop :)

Share this post


Link to post
Share on other sites

It works with 1.7.2.4  :)

But how do I change the starting/next number? Now it starts with 000001 but is it possible to change something so it will start with no. 21400?

 

Share this post


Link to post
Share on other sites

Hello Daresh,

 

module installed, but when did testinf order on my site (shipping method Geis, payment method COD) -> then i get ERROR 500.

See the files below, thank you for your answer. Thats module is great and i would like to use it.

Petr.

Error 500.jpg

Settings.jpg

Share this post


Link to post
Share on other sites

It seems to be unrelated, cause looking at the reference number, the module's override is not active, reference is still a random character string.

Share this post


Link to post
Share on other sites

Hard to tell without analysing it totally, maybe some conflict with other overrides. In this situation I would try to add the override manually in the Order class.

Share this post


Link to post
Share on other sites

Thank you. But i dont know where and how do override. Thank for your help. I try another way how to change ID of orders.

Share this post


Link to post
Share on other sites

Thank you, Daresh, for this module! 

You'll be update module for PS 1.7.3?

 

Share this post


Link to post
Share on other sites

Hello,
it´s me again :)   I am wondering if i can realize the following count up with this module in combination with the Prestashop possibilities:

We need order numbers like this (just an example):

13460x
13461x
13462x

plus one attached check-digit at the end  (this means the x).

So finally it should looks like this e.g.:

134602
134618
134624

the check-digit has not to be any mathematical plausibility, it can be any number in random arrangement.

Or:  it can also be to count up the second last digit with this module in random and add one increasing digit at the last?

Is this possible in any way ??
thank you,

Edited by DRMasterChief (see edit history)

Share this post


Link to post
Share on other sites

Sure is, just modify the return in the override:

return $prefix.$reference.rand(0,9);

 

Share this post


Link to post
Share on other sites

Great to hear that this should be possible and thank you for this fast reply.  But.... uhh i am not that expert and did not know what to do with your code  :unsure: 

I can´t find this code in your module.

Edited by DRMasterChief (see edit history)

Share this post


Link to post
Share on other sites

I uploaded the .zip, but the module does not show up.
Which word should i use in der search bar?  

im a Presatshop 1.6.1.17 user

Share this post


Link to post
Share on other sites
On 2015/12/29 at 5:46 PM, Daresh said:

Many shop owners don't like the default random string order reference, but changing it to order ID reveals the number of orders to customers.

 

This module changes the order reference tu numeric and let's you choose between a random number and order ID, you can also add custom prefix and choose to have leading zeros.

 

post-653890-0-53248900-1456658636_thumb.png

 

post-653890-0-31925600-1460916559_thumb.png

 

Module works for Prestashop 1.5, 1.6, 1.7

 

I am sharing this module for free on my most common improvements subscription list on http://greenmousestudio.com/ or below.

 

gmnumeric.zip

 

Update 16.08.2016

gmnumeric_v_1_2_0.zip

 

A few notes in case this module does not work for you and you need to uninstall it:

- this module overrides generateReference() function from the Order class, sometimes (I don't know why) Prestashop leaves the overriden files after uninstall, so check the "overrides/classes/Order.php" and remove the generateReference() function or delete the whole file if there is nothing else in it.

Thanks for your great module.

  • Like 1

Share this post


Link to post
Share on other sites

Hi Daresh,

I'm using your original module from 2015 on my PS 1.6.2 store. It works great but I decided I want to randomize my order ID. Below is my order.php override. What do I need to add to randomize the numbers? Thanks!

 

<?php
class Order extends OrderCore
{
	/*
    * module: orderreferencenumeric
    * date: 2015-10-18 22:46:38
    * version: 1.0.1
    */
    public static function generateReference()
	{
		return Tools::passwdGen(9, 'NUMERIC');
	}
}

 

Share this post


Link to post
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

×

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More