View Single Post
  #5  
Old 03-30-2020, 11:20 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,190
 

Default Re: Custom Order Numbering

Quote:
Originally Posted by The Knotty Celt
Thank you. That, unfortunately, does not suit my needs. It applies a prefix and suffix to the order number, but the order number itself continues to increment. I am looking to have intuitive order numbers where the sequence resets each year, and the current year is pre-appended.




You will need to make a lot of changes to avoid issues with orderNumber.
While the type in the database for this field is varchar this is the only place where orderNumber is treated as string. Everywhere else orderNumber is treated as integer. This was pointed out to XC veeery long time ago and I simply do not see them willing to change this behavior.


If you start recording orderNumber as string, meaning the field having non-numeric characters, you will break orders search (both admin and customer), next/prev order, eventually payments and everything else that depends on orderNumber.
Not to mention orderNumber is cast to (int) numerous times within the code, both for PHP and MySQL.


If you keep it as number but start resetting it every so often you will end up with multiple orders having the same orderNumber which will again screw up lots of functionality.


Unfortunately XC is coded within its core to work with orderNumber instead of orderId for lots of functions and behavior.


For what you want your best bet is to have it say 202000001, then next year reset to 202100001 and so on. This will not cause any issues with current code. And you can easily set this at the beginning of every year through admin cart settings - next order number.
Then you can use the module I mentioned to just add the SO/ prefix.
And in this case you cannot have 2020/00001 as orderNumber as the / will mess things up.
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote