Hi Everyone, I have a problem, I've created a shopping cart in php, this is what happens: -When a user presses the add button on a gallery page it adds the details of the item to the shopping cart. -This works perfectly fine. -What I really need help with is, how I can let the user see how many items they have in their shopping cart on other pages while they are still browsering the site. -So once they pressed the add button it will show the total quantity of cart. I hope this is clear enough. Thank you
I'm assuming your shopping cart runs on sessions (sensible ones normally do.) Surely you could just use session_start(); on a page, then read the session variables from there? The only data you really need to hold is the id number of the product in question and the quantity, and you can just multiply up from there. Dan
To Danltn, I not sure if I understood what you saying, coz Im very new to php, it would help if u could show me an example! yes I am using session. Example of what I want to do is like on an amazon site, where when a user clicks add, it shows the user the item in the shopping basket, all I want it to do is count the total quantity and display it, even if the user goes on other pages in the site. Thank you
This is something I came up against. Rather than use the session objects if you want to get tricky, look at ajax, I ajaxified a shopoping cart system i wrote for a client, so all items added to the cart were done via ajax calls, I then had a widget, or box that simply queried the data from the cart, on cart pages, the ajax function that ads to the cart, also updated the widget. On non-cart pages, it didn't really need to have ajax, so I run a straight query in the widget that grabs the data. However on mine sessions were consistent across the site, and I could use that as a pointer to the data
When you build your ajax shopping cart, I'm sure you create a way to delete all junk data from your database when people start shopping and never checkout.