Hi ho,
I'm finishing off a shopping cart and I have one or two issues that I could really use some help with.
Basically, when I started the cart I was using sessions to store whatever was in the shopping basket (and it worked very well). HOWEVER, when I moved all of the checkout pages over to SSL I found that I was losing all of my session variables when I crossed over to the secure pages.
So, eventually I decided to rebuild the cart from scratch and am now using database tables to track what the customer does.
So, when a customer comes into this shop and puts something into the shopping basket, the item number (for the product) is stored in a database table called shopping basket. That, as well as the quanity, the customer's IP address, the session ID and the date/time that the object was put in the cart.
Then, when the customer goes to the checkout and fills out a form, all of the customer's details go into a database table called "customer_details". This particular table has columns for name, address, bla bla bla... and well as columns for IP address and session_id.
So, when the shop manager logs onto the shop to check for new orders, the admin page (for checking orders) simply matches from the two tables where session ID and IP are the same.
The entire method that I've described is consistant with the approach that's recommended in the Sam's "Teach yourself PHP, MySQL & Apache" book.
But there are two problems.
The first problem comes with the fact that over time the shopping_basket table is going to get clogged up with lots and lots of entries. Indeed, many of the entries that get entered into the table will never even be purchased at all. So, my question is... How can I ensure that the garbage from the shopping basket table is regularly cleaned out?
The second problem I have is this.... when a customer goes through the entire checkout process, they will come out at the end with two database tables to their name- one that stores their shopping basket and another for their contact details.
My question is therefore this... Is there any way that I can clear the customer's basket after they've gone through the checkout???
This is not as serious as the first problem, but my big fear is that the customer goes BACK into the shop after placing an order and finds that their old basket is still there.
Any advice would be appreciated. Thanks!