Advanced Ordernumbers for VirtueMart
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Sometimes generate strange numbers

Sometimes generate strange numbers 21 Aug 2017 13:40 #1

  •'s Avatar Topic Author
  • Offline
  • Posts: 1

we have some problems with numbers of order = sometimes plugin generate strange numbers and we can't understand why it happened and how to fix that - please help us.

Current settings is in PrtScr below
Version Joomla 2.2.5, VM 2.0.20b, PHP 5.3.3-7+squeeze28

Thank you very much
web support

Please Log in or Create an account to join the conversation.

Sometimes generate strange numbers 24 Aug 2017 21:18 #2

Whenever an order is assigned a number that already exists, VM by default appends the current date/time. This is exactly what you observe. As your order number format does not contain any counter, whenever a new order generates a four-digit random number that was already used, you would have two orders with the same order number, so VM appends the date.

There are several approaches to this issue:
1. Include a counter in the number format, e.g. [year2]#[randomDigit4]. Then whenever a random number is generated that was already used, the counter will increase to 2 for that random number and no duplicate number will be generated. The drawback is that this basically generates a new counter (which is basically just one database entry, so no big performance hit) for each order.

2. Use a longer random number, e.g. [year2][randomDigit10]. While this will not prevent duplicate numbers, the probability that two orders will get the same random number will be very low and the situation you observe should hardly ever happen.

Best regards,

PS: You might think that the apparent solution would be for the plugin to check whether the order number generated is already in use and simply try to generate a new number. The problem is that this might lead to infinite loops. Imagine a number format of "[year2][randomDigit2]". When the 101th order comes in, there is simply no free order number left, so whatever random number is generate, it will always be in use already.

Please Log in or Create an account to join the conversation.

  • Page:
  • 1