Question

My question is, how unique is the incremental order Id? The payment gateway I'm using requires a unique order Id for every purchase attempt.

So let's say customer A tries to purchase, but his transaction is denied.

Order ID: 1, Increment Order ID: 100001

When he tries to purchase again, will the Increment Order Id become 100002, or will it still be 100001? And if so, how do I refresh/increment it?

Also, will it be unique across customers? Will an Order ID: 2 have an Increment Order ID: 100001? Or will it be unique across all orders?

Was it helpful?

Solution

It is globally unique, which is even assured on database level.

This is the code from app/code/core/Mage/Sales/sql/sales_setup/install-1.6.0.0.php where the order table gets created:

->addIndex(
    $installer->getIdxName(
        'sales/order',
        array('increment_id'),
        Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE
    ),
    array('increment_id'), array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE))

Also if a customer tries to order again after an aborted order which is already in the database, a new order will be created.

OTHER TIPS

The order (and invoice, shipment, creditnote) numbers are unique all over the application.
But they might not be consecutive for various reasons.
For example, the store view id is used as prefix for the order numbers.
So if you order from store view with id 1 you will get the number 100001.
Then if the next order is from store view with id 2 you will get the number 200001.
The next order from store view 1 might have the number 100002 but it may have a bigger number if some payments failed between (or if some carts were abandoned and some certain conditions are met).
Also you cannot have 2 orders from different customers with the same number.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top