WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Bakery Shop => Topic started by: bart538 on December 21, 2010, 04:00:51 PM

Title: Assigning order id at the last possible moment.
Post by: bart538 on December 21, 2010, 04:00:51 PM
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.
Title: Re: Assigning order id at the last possible moment.
Post by: bart538 on December 29, 2010, 07:16:19 PM
*bump*
Title: Re: Assigning order id at the last possible moment.
Post by: mjm4842 on January 08, 2011, 08:28:24 PM
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
Title: Re: Assigning order id at the last possible moment.
Post by: PurpleEdge on January 09, 2011, 01:05:47 AM
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.