Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 1 of 7
Custom order number, or at least custom starting number
 
atlantide
Sr. Member
 
Avatar
Total Posts:  187
Joined:  2008-02-16
France
 

I don’t like when customers see the exact number or order I have already done.

Ex : order n° 100000079 is very revelant…

Could we be able to custom the order number with different variables ?

Or at least, could we choose a different starting number for orders (and invoices), like starting from 3453135215 ?

Thank you

 
Magento Community Magento Community
Magento Community
Magento Community
 
golles
Sr. Member
 
Total Posts:  257
Joined:  2008-01-15
 

did you ever work out a way to do this? i would be interested too.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Dreamlabs
Jr. Member
 
Total Posts:  2
Joined:  2008-04-17
 

Hi,

small businesses often use an existing book keeping software and can’t just stop with their current order numbers.
I have a client for example which uses the series 90001 - 99999 for their webshop.

 
Magento Community Magento Community
Magento Community
Magento Community
 
ericleeclark
Member
 
Avatar
Total Posts:  40
Joined:  2008-02-02
Muncie, IN
 

I have a feeling this can be changed in the database, probably in the sales_order table, increment_id field. Though I’m not sure. I’m looking into this for myself as well so if I figure it out I’ll post a reply.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

Look in table `eav_entity_store`

 
Magento Community Magento Community
Magento Community
Magento Community
 
ericleeclark
Member
 
Avatar
Total Posts:  40
Joined:  2008-02-02
Muncie, IN
 

Thanks, Moshe. Would it cause problems if I changed the length to 6 characters? It’s still VARCHAR(50), just want to reduce the length of the number and also match a 3rd party accounting system.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

Run this on your database:

update `eav_entity_typeset `increment_pad_length`=6 where `entity_type_code`='order';
This should do the trick.

Don’t forget to clean EAV cache.

 
Magento Community Magento Community
Magento Community
Magento Community
 
ericleeclark
Member
 
Avatar
Total Posts:  40
Joined:  2008-02-02
Muncie, IN
 

Excellent, thanks for your help!

 
Magento Community Magento Community
Magento Community
Magento Community
 
whoscart
Sr. Member
 
Total Posts:  120
Joined:  2008-02-23
 

I’m a newbie when it comes to databases. Could someone tell me exactly where to go and what to do if I want my order numbers to start from 123456?

 
Magento Community Magento Community
Magento Community
Magento Community
 
beowax
Sr. Member
 
Total Posts:  94
Joined:  2007-12-17
Lille, France
 

Hi,

I too, want to mak a custom order number, such as “WEB1/1” + date("y") + bin2hex(Number of order +1)

I tried to override the Mage_Sales_Model_Order model (getIncrementId and other methods), but it seems not to be interpreted…

I took a look at the eav_entity_store, in order to realise this, but it sems impossible. I only managed to had the “WEB1/1” prefix… not the year (08), nor the number of orders in hexadecimal.

This is very important for me to manage that… Can somebody tip me on the way to realize this ?

Regards,
Antoine

 
Magento Community Magento Community
Magento Community
Magento Community
 
nicolas46
Sr. Member
 
Total Posts:  210
Joined:  2008-04-09
Toulouse
 

i would be interested too.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

Examples of increment logic are in app/code/core/Mage/Eav/Model/Entity/Increment/ folder.

They are configured for respective entities in table eav_entity_type, field increment_model.

Current data for each entity type and each store is stored in eav_entity_store.

 
Magento Community Magento Community
Magento Community
Magento Community
 
alistek
Sr. Member
 
Total Posts:  293
Joined:  2008-04-02
Normal, IL
 

Hello,

After taking a quick look at this, it seems that although you might not be able to add the prefix directly into the SQL database if you want to add the functions there you have one of two options.  Either you modify the numeric.php increment function to use your custom values or you change the incrementing model that it uses to a custom one and you use your custom values there.

I would say that everything you need is fairly easy to change.  In the table eav_entity_type you can see that entity_type_id = 11 is what will control the sales/order increment number.  Under the column increment_model is what defines what model it uses to increment.  By default it is set as eav/entity_increment_numeric.  Say you wanted a custom model in there and you wanted it called customincrement.php you could put eav/entity_increment_customincrement under the column increment_model and it will use that custom function.  Keep in mind you might have to tell Magento that you added a new model but you get the point.  Now there are a few more options in there, you can see that the increment_per_store column is set at 1 which means that it will go up just one at a time (I am fairly certain but I would have to check) adn increment_pad_length is the number of padded characters added.  And increment_pad_char is for what character will be added there for padding.

Now if you go to the table eav_entity_store you will see that there is a row with entity_type_id = 11, this corresponds to that same entity type and you can see that the increment_prefix is stored there (which should only be alphanumeric characters) and the increment_last_id is there.  Fairly self explanatory.

Now let’s look at the file Numeric.php under the increment folder.

<?php

class Mage_Eav_Model_Entity_Increment_Numeric extends Mage_Eav_Entity_Increment_Abstract {

public function getNextId()

$last $this->getLastId() //This will pull from the database the increment_last_id field

//This handles the padding and you see that getPrefix corresponds to the field increment_prefix, if you prefix getSomething then whatever table
//the model is linked to will pull from that database field, i.e. getSomethingToTest will get something_to_test as the field name
if (strpos($last$this->getPrefix())===0{
$last 
= (int)substr($laststrlen($this->getPrefix()));
else {
$last 
= (int)$last;
}
$next 
$last+1;

return 
$this->format($next);
}

Ok so we want to make this function add something to that, well right now it is being casted to an int hence the (int) but if we want to do something with the alphanumeric characters you should look at Alphanum.php, essentially the same thing just with some more checks added for allowed characters.  But you wanted to do something like:

WEB1/1” + date("y") + bin2hex(Number of order +1)

$next $this->getPrefix() + date("y") + bin2hex($last+1);

You would probably want to do this in Alphanum because it will be expecting a return from an alphanumeric and not from an integer.  In addition, you will want to do more checks but you get the point.

-Adam

 
Magento Community Magento Community
Magento Community
Magento Community
 
Sander
Sr. Member
 
Avatar
Total Posts:  232
Joined:  2008-01-08
Netherlands
 
Moshe - 24 April 2008 06:27 PM

Run this on your database:

update `eav_entity_typeset `increment_pad_length`=6 where `entity_type_code`='order';
This should do the trick.

Don’t forget to clean EAV cache.

I removed all cache, then made the above database edit, edited the last_increment_id in eav_entity_store to a 6-digit number, then refreshed all cache, but there’s still a 9-digit order number when a test order is placed. I can see that the increment_pad_length is correctly set to 6 in the database, so I don’t really get what’s going wrong. Any ideas? Thanks in advance!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Vivendo.
Jr. Member
 
Avatar
Total Posts:  3
Joined:  2008-04-01
Hilversum
 
Sander - 12 June 2008 08:15 AM

Moshe - 24 April 2008 06:27 PM
Run this on your database:
update `eav_entity_typeset `increment_pad_length`=6 where `entity_type_code`='order';
This should do the trick.

Don’t forget to clean EAV cache.

I removed all cache, then made the above database edit, edited the last_increment_id in eav_entity_store to a 6-digit number, then refreshed all cache, but there’s still a 9-digit order number when a test order is placed. I can see that the increment_pad_length is correctly set to 6 in the database, so I don’t really get what’s going wrong. Any ideas? Thanks in advance!

Update for future reference:
Changing increment_pad_length in the database didn’t work, I extended Mage_Eav_Model_Entity_Increment_Numeric and Mage_Eav_Entity_Increment_Abstract with local classes to get the desired padding.

 
Magento Community Magento Community
Magento Community
Magento Community
 
btbc
Sr. Member
 
Total Posts:  95
Joined:  2008-06-11
 

I used to run an Oscommerce site, and used an awesome contribution…

http://addons.oscommerce.com/info/2499

Basically, the order number for the store owner, magento, and the back end will be correct (#1000459 for example)… but on the customer’s invoice and account, it’ll show order #A497583.

If the member needs help and gives you the order #A4975B3, you just search for that order number and Magento automatically decrypts that number to the correct number on the fly.

Again, my memory is fuzzy, but I feel that this is the best way to handle the order numbers. I personally don’t like customers or competitors to know how many orders I do daily/monthly…

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 7