How do e-commerce orders process work when checkout?
May i know is the purchase order being created when customer clicked on checkout before payment made? The created purchase order payment status will be set to unpaid and pending the payment. And also the purchase order will be cancelled after a certain period if status still remain unpaid. The purchase order will only seen by the customer self without sending to vendor until payment made.
I think the best case scenario is to put all the data you need into the session. And once customers paid for their orders pull out the data from the session and create the orders. This way you don't need to clutter your table with unpaid orders.
But this all boils down to your website's requirements.
@Crazylife There is no one way on how “e-commerce” works. How and when an order is created depends on your business rules. Some businesses (and software) create the order before payment is taken (so the order is “open”). Other create the order after payment has been taken (i.e. in a callback from a payment gateway).
Work out how your business works “offline” and you’ll have a better idea if you need to create the order before or after payment.
It depends on the checkout solution as well. A lot of checkout solutions requires and order to have already been created when you send that information to the thirdparty payment provider when generating the checkout page.
If we take a look at woocommerce for example, they store cart/order into a session, then they serialize that session to the database and once order is complete they move that to an order.
Keeping it in the database in the end would allow you to track "lost" orders, and you could perhaps even email those if they have gone so far as given you an e-mail address before they left, that's quite common these days.
Most e-Commerce systems have a temporary order object sometimes reffered to as a Quote which could be considered the cart. this contains all the information needed to create an actual order.
Some payment systems however require an actual order_id before a transaction can be made so some e-commerce systems will actually be forced to create an incomplete order and await the client input ( usually they have a timeout of 30-60 minutes before they cancel / delete the order in order to clean up after customers who close their payment gate too early )