How to Prepend a char to order no?

Hi Members,

How can I prepend char ‘B’ to order no??

I checked order.tpl under oxid-e-sales << vendor, but I am not getting it. Kindly request your help.

Thanks

You want to make order numeration like “1234B” where 1234 is next order number and at the end there is always B?

B should be at first, like B1234 and then for next order, it should get incremented to B1235.

OXORDERNR is INT type in database. Soo you can’t do this.

yes exactly… so alternate solution for this??

Earlier requirement was to generate order no. from 50000 and I did it by changing the value in oxcounter…
But now I hoping for some solution to achieve this…

If you want full support for this for example also in mail notifications and all views, then you will have much work with extend tpl blocks, etc.

Better way is to implement you own order numeration.

1 Like

first guess would be to overwrite the getNextBillNum() method in the order model with a module.

like this in vendor/oxid-esales/oxideshop-ce/source/Application/Model/Order.php line 1549:

return ( \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->getOne($sQ, false) + 1) + “B”;

but no gurantee, you have to look for yourself how it behaves…

1 Like

Okay Thank you for guidance. Let me try :slight_smile:

Hey JB,

Do I also have to change the column ‘ordernr’ structute to varchar in DB??

Also If I am not wrong, getNextBillNum() function is for invoice number, right??

Friends,

I have created module for overriding a function which is from vendor>>model >>order.php but not able to achieve it…I want to override a function called _setnumber() from vendor/oxid-esales/oxideshop-ce/source/Application/Model/Order.php. I just want to add one line of code $iCnt = ‘B’.$iCnt;
Please help.

Thanks,
Wasim

Are you able to show your module? Then we don’t need to guess… :wink:

Hey @wasim,

I am not sure you have already checked, but the oxorder.oxordernr field in the database is of type INT(11) so you can not store a string in there.
MySQL is not complaining, because in most cases it is not running in strict mode (which I would recommend to set to STRICT_ALL_TABLES).
In its default sql-mode MySQL does magic casting for you (as PHP would do). So if you insert the string B12345 into an INT(11) field, MySQL will cast this and just insert 12345 into the field. You may be able to fetch a warning informing you about this, but setting SQL-Mode to STRICT_ALL_TABLES will fail with an error in such a case an not cast.

Hope this helps

/Flo

So, I maybe should have read the whole thread :crazy_face:
Never mind

1 Like

Thanks all. Finally I achieved it :slight_smile:

I was missing to add namespace which was in vendor… I was using: extends filename_parent instead of OxidEsales\EshopCommunity\Application\Model\Order

1 Like