• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Ordering process advice needed, ?_POST vs. DB

#1
[eluser]bjora857[/eluser]
On my website I sell customized art. The ordering process consists of 7 steps.

Step 1. Style. Specifying what style you want on the art. 8 styles are available.

Step 2. Options. Each style has different options. for example if the customer has chosen style A she can specify which colors,
if the customer has chosen Style B she can chose if she wants a lion or a monkey in the background. etc.

Step 3. Size. Here the customer can chose which size she wants the art in. Different styles are available in different sizes.

Step 4. Mounting. Here the customer can choose if she wants it mounted or not.

Step 5. Customer info. Name, adress, phonenumer etc..

Step 6. Summarize of the order.

Step 7. Thanks for your order page.


This ordering process now works. I use validation and repopulating. Every step is a different page, and I use the $_POST array to send
the info through the ordering process. ##I use if($_POST[’style’]==styleA) { show some Options}.... to show different options depending on choices earlier in the process.#and form hidden fields to send info through the different steps.

If the customers clicks all the way through to step 7, all info is being sent to a database and a order is placed.



Now to my question... Is there a better way to do this? I have to use hidden fields and the code is kind of messy.

How would you construct the ordering process?

I was thinking of inserting into the DB after each step, but what happens if some just clicks through to step 4 and then leaves.
How do I clean up the database so I only have complete orders?
Could it be problems if there are several customers are ordering at the same time?

Thanks in advance
/ Björn

#2
[eluser]jabbett[/eluser]
You should store each selection in the user's session. You get cleaner code, and if you initialize the session appropriately, your user can automatically return to the ordering process at the step he last completed (e.g. if he browses away).

See the section of the User Guide that deals with the Session class for more information.
http://ellislab.com/codeigniter/user-gui...sions.html

#3
[eluser]Chris J Smith[/eluser]
No no no - don't use the session for this. Keep the user id and retrieve the order steps from the database. Work out what data needs to be persisted at each step and populate the order entry / lines accordingly.

If you use session and change the structure of the basket stored in the session (during say an upload), you will corrupt any earlier sessions therefore leading to errors.

#4
[eluser]bjora857[/eluser]
I dont know what is the "best" way to this, but to me sessions was the easiest way of doing what I wanted to do.

I used $_POST to get data from one step to another and then from $_POST stored the data in session-variables. At the last step I write all data in the session-variables to the database.

#5
[eluser]obiron2[/eluser]
log the cart in the database for a number of reasons.

1) Your ordering process is complicated, your customers may need to consider their actions and recall a part completed order
2) It allows you to monitor who is using the shopping cart and where they are abandoning the process which should allow you make changes and reduce the abandonment rate.
3 In the event of a client side failure - dropped connection, closed browser etc. The cart can be retrieved (subject to your customers loggin on or having some sort of IP recognition in place)
4) You will need to store this information in the database at some point so it is better to do it as you go.
You will need to have a process that cleans up abandoned carts and/or releases reserved stock.

Obiron

#6
[eluser]jabbett[/eluser]
Certainly, a database will be necessary at some point, you'll just need to choose when is the right time to go from session to database. I'd say that while the data is in flux (e.g. while the user is building his product, or while the user is going through the checkout steps) keep the data in the session. When the data is in stable condition, add it to the database.

So, perhaps-- keep product choices in the session store (steps 1-4), but add the product to a cart table when the selections are complete. Then, during checkout, keep the personal information in the session store (steps 5-6), and add to the database when the order is confirmed.

A full-blown database approach will work, too, and Obiron's recommendations are equally valid.

#7
[eluser]bjora857[/eluser]
Thanks Jabbett, Obiron, Chris for all advice. I will stick to the sessions approach, because its easier to implement and it works good for my demands. But if someone wants more functionality, the db-approach might be more suitable.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.