• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

PHP Question regarding a shopping cart.

Jadenrose

Weaksauce
Joined
Apr 30, 2005
Messages
102
Hey you guys. I am currently working on a php shopping cart that will in the end link up to Google Checkout's API when the customer goes to check out. I want to be able to let customers select and buy multiple product with different options, and have those options transmit to Google so that we can see exactly what options they've asked for.

What I have in mind, is that they choose their options on the product page and add it to the cart. Then the cart will update according allowing them to shop more, or if they are ready to check out, to select their shipping and then hit the Google Check-out button.

Here's my issue, however. I have thought about using a database to keep track of orders and have use sessions to keep track of the customer and their cart, so the contents of the cart are not lost, where I can set an expiration of so much a time, that if they have to leave and come back, their cart isn't lost. With using databases, I do not want to have to go in and manually purge information on a daily basis. Also, how hard would it be to implement a db that has two tables (an orders table that keeps track of an order_id and total and an orders content that adds each type of product into that one, and sorted with the order_id that is passed to notate which cart it belongs to) and have those two tables be called upon to populate the cart when they go to view the cart.

Any help is greatly appreciated! Also, alternative suggestions on a better or easier way are acceptable.
 
Write a script that deletes orders that are more than, say...2 weeks old. Then run it every night as a chron job.
 
Thats an idea to look into. Will have to keep that in mind for later when I get the cart done.

Still wondering those if all the db connections and such to keep a cart updated, tho, is the way to go or not.
 
You could create a single table then give each session an id and use that to track the items in the cart for that session. This would add quite a bit of load for any decent sized site though.
 
You could create a single table then give each session an id and use that to track the items in the cart for that session. This would add quite a bit of load for any decent sized site though.

All that does is transfer the load of session management from the application to the database. And in reality, it might be better to have this put in the database. You could control what sessions are active and (with some proper app coding) gracefully logoff users if you had to do some maintenance.
 
Back
Top