Is it possible to assign an order number to an order before it gets finalized?
I have a saved basket system where customers can have multiple saved baskets, and they would like to have a reference number on them which will then become the order number. I'm not sure of the best way to do this, I understand it should be possible to generate the next order number and assign it as a property to the saved basket, but there is the likely chance that another order will be finalized before the saved basket is placed as a real order, and so that order number saved as a property would be already taken.
I'm not sure what the best approch would be here, but need a solution fairly quickly (don't we all..).
That was rediculously simple, fantastic! I actually just changed the prefix for the CartNumber and then as you said, updated the OrderNumber in the finalized event updated the OrderNumber in the Order Created event to be the CartNumber (changed the CartNumber prefix to be ORDER-), so there's no possible duplication etc. as Tea Commerce is managing the CartNumbers for me.
The only issue with this is that the order number doesn't get incremented in the db at the same time. Not a biggy as it shouldn't then be being used, but I'm thinking I can use GetNextOrderNumber(true); in the order created event against the store model to keep the cart and order numbers in sync? I haven't used it yet as I'm currently facing another issue with retreiving my storeId at that point, but I'm guessing it should work?
Assigning an ordernumber before order is finalized
Hey all,
Is it possible to assign an order number to an order before it gets finalized?
I have a saved basket system where customers can have multiple saved baskets, and they would like to have a reference number on them which will then become the order number. I'm not sure of the best way to do this, I understand it should be possible to generate the next order number and assign it as a property to the saved basket, but there is the likely chance that another order will be finalized before the saved basket is placed as a real order, and so that order number saved as a property would be already taken.
I'm not sure what the best approch would be here, but need a solution fairly quickly (don't we all..).
Any pointers welcome!
Mark
Hi Mark
You should assign your custom order number in the event OrderFinalized.
Kind regards
Anders
Anders,
That was rediculously simple, fantastic! I actually just changed the prefix for the CartNumber and then as you said, updated the OrderNumber in the finalized event updated the OrderNumber in the Order Created event to be the CartNumber (changed the CartNumber prefix to be ORDER-), so there's no possible duplication etc. as Tea Commerce is managing the CartNumbers for me.
The only issue with this is that the order number doesn't get incremented in the db at the same time. Not a biggy as it shouldn't then be being used, but I'm thinking I can use GetNextOrderNumber(true); in the order created event against the store model to keep the cart and order numbers in sync? I haven't used it yet as I'm currently facing another issue with retreiving my storeId at that point, but I'm guessing it should work?
Thank you again!.
Mark
is working on a reply...