I have never created one but id say you should use sessions and database to store the items added and the session id then when they logout or whatever delete everything from database where the sesion id=session id. obviously loads more stuff but thats probly one way.
Presumably, you have the items from your store set up in the database with some kind of identifier/key. All of the pricing and descriptive information should be stored there, so your shopping cart will just need to store the item id for reference.
Then, you should decide how long you want the shopping cart to last. If you use sessions, as previously suggested, it will only last until the browser is closed. You might also want to have a longer-term cart, so that if the user is interrupted for some reason the cart will remain full for a few days.
The format of the cart table or array would be pretty simple. One field would hold the user's id (unnecessary if you're just using cookies or sessions, but necessary if you're using a database table). The second field would contain the item id. You could then include a third field for quantity, or just duplicate quantities in the table rows. If you duplicate the quantities, you would just need to use GROUPBY and COUNT to get the proper quantity for each item.
If you join the cart table to the item catalogue table, you'll get the prices. Then you can add everything up, get a sub-total, put in whatever formula you want for shipping, and voila you've got a total. The harder part, methinks, is implementing that with a payment system that is secure.
I find that the easiest implementation of a paypent portal is to sign up for the PayPal service and use their code to send the purchase to them. They will then handle all the payment stuff required. This saves you a lot of money because you won't need to purchase an SSL cert. nor pay credit card handling fees (for the most part).
Can you share to me a database structure for a shopping cart...
I am very experienced with Shopping cart, i have worked on so many cart like osCommerce, Zencart, etc.
I will suggest to you that you can use osCommerce for your shopping cart, it will be better option for you. If you want some help on that you can send me PM.
Try to work your way around with paypals IPN scripts because they are a good way to process payments online.... for FREE!!!
need any help?? don't hesitate to contact me