R
R
Rustam Idrisov2017-04-06 13:29:12
MySQL
Rustam Idrisov, 2017-04-06 13:29:12

How to properly implement checkout on multiple pages?

Good afternoon!
Now I'm making an online store on Laravel - the essence is as follows:
I need to implement checkout on several pages (different stages of checkout - Contacts/Delivery/Payment).
Let's call these stages step1, step2, step3.
Problem - there is a table of orders in the database (orders), which stores data from all three stages of ordering.
I do all the validation on the backend using standard Laravel tools.
Question: how to correctly transfer data between the stages of ordering. That is, there is a form on each page -> the user has filled out the form -> the data has been validated -> as soon as "everything is ok" we go to step2, step3. And finally, at the end of step3, you need to write the order data to the orders table.
I don’t understand how to store data correctly so that if the client returns to any previous stage, the data is “pulled up” and he can change it and finally write the data to the database at step3.
How to do it safely so that the data is protected and, for example, an attacker could not bypass the validation.
I would be very grateful for your help!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Z
Zlatoslav Desyatnikov, 2017-04-06
@RustaMechanic

There are two ways:
1. Write data to the orders table at each step and separately validate each step, but set the status of the order to "draft". Switch to active status only if the third step is sent and all three are valid (you need to check)
2. Write the order status to the session and validate all the data once in the last step.
The first option will allow you to continue placing an order in another session + you will see the so-called "abandoned carts", managers will then be able to contact the client and find out what is wrong and, maybe, increase sales.

V
Voll., 2017-04-06
@vollthegreat

I decided by writing the data to the order basket. Or to the session (if not registered). Since the basket for each user is in fact one, as are the "order steps".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question