I have got a strange issue with Order Number in Magento.
Recently when one order was placed on my website the Order number came was 100000350
,Ideally it should have been 100000370
as my previous order numbers were 100000369
and 100000367
. I have attached the screenshot below for it
Moreover, I have checked for the error logs but haven't found any entry of it. We are using SagePay and PayPal as the payment gateway for it.
Can anyone guide me on this?
Best Answer
The first time I got an out of sequence number, we had surprise and some dismay until I figured out what was happening. It has to do with how Magento allocates Sales Order numbers.
Now for the explanation.
The Magento order process creates a quote the first time something is added to the cart.
At this point, the quote is a potential Sales Order only. It has no assigned number because the customer has not committed to paying for it.
As the customer clicks the Proceed Button to checkout, they will:
What follows is an important bit: The customers who choose to register in the cart are treated as guest customers till the order is completed and they get to the success page, at which time their account is created and they're logged in. The quote remains a guest customer quote with the session timeout loss of cart if the order is not completed and a success page displayed.
With a credit card order, the following happens when the Place Order button is clicked.
sales_flat_quote
table in thereserved_order_id
column)If the credit card transaction is declined for any customer by the credit card payment gateway, and the next customer places a successful order there will be a skip in the Sales Order number sequence due to the declined payment Sales Order being assigned a reserved Sales Order number and the following successful Sales Order being assigned the next available number.
For guest carts (guest orders and unsuccessful register in cart customers) that exceed the session timeout, this reserved Sales Order number will be lost when the session expires, leaving gaps in the Sales Order sequence.
For customers who logged in before clicking the Proceed Button, the quote is assigned a customer id, so if they attempt to place an order and find that it's declined, they can come back, log in, find the cart still has contents and place the order, sometimes much later (longest to date was four months). The quote will use the assigned reserved Sales Order number, leading to an out of sequence Sales Order number showing in your Sales Order management display.