2

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?

3

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.

| improve this answer | |
  • Thank you for your great answer. How do I force an order to get a new increment Id? I want to make sure every time I call the payment gateway, I'm sending a new, unique one. – Pat Jul 15 '15 at 9:00
  • 1
    I never used it and doubt that it is really necessary or a good idea at all but you can enforce re-assignment of the increment id with: $order->setIncrementId(null); $order->getResource()->setNewIncrementId($order) – Fabian Schmengler Jul 15 '15 at 9:09
1

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.