Assigning order id at the last possible moment.

PurpleEdge

This is a universal problem with all ordering systems that use the database autoinc value as the order number.

Two alternatives often used...

1. Use another field value as the order number, and populate that from a pool of available numbers, or only populate it when the order is confirmed. (Need to allow for deleted and cancelled orders, not just incomplete orders)

2. Save the order in a temporary storage - not in the database, and when the order is confirmed transfer the order to the database, creating the autoinc value at that time. In the web world cookies are often used as the temporary storage area - not sure how Bakery does it?

Neither is particularly easy to code, so the common approach is to live with gaps in the order numbering, or flag incomplete and deleted/cancelled orders appropriately and leave them in the database, so you won't get gaps in the order numbering, but you will have a lot of "dead" orders.

mjm4842

There isn't much that can be done about the order numbers not being sequential. However you could modify the code in such a way that invoice numbers would only be generated upon payment. It would be possible to ensure that these are sequential. I think this would address your concerns as long as all orders are paid for.

Michael
Frustrated? Spending too much time developing when all you really want is a working website? Contact me directly if I can be of services to you.
___________________________


www.tngconsulting.ca


bart538

#1
I'm having the following problem:
When people are adding products to their cart, they get an order number.
But when they don't finish their order, this number has been used.
In my list of completed orders I'm getting order numbers from 1,2,5,10,23 etc
So I'm getting a lot of skipped order numbers. Ideally I would like to have a list of completed orders from 1,2,3,4 etc. for my administration.

I would like to get some suggestions on how to fix this.
I'm thinking about assigned the order id at the last possible moment, but don't know if this is the correct solution.