I'm creating a simple shopping cart app.
I have a button which launches $PHP_SELF? followed by variables (product id, qty, price etc)
the cart works fine, apart from updating the first purchase, which requires two button presses...
the code that is called when the button is pressed looks like this
Expand|Select|Wrap|Line Numbers
- if (!isset ($_SESSION['cart'])){
- session_start();
- if (isset ($_SESSION['cart'][$prod_id])){
- $_SESSION['cart'][$prod_id]['qty'] += $qty;
- }
- else{
- $_SESSION['cart'][$prod_id] = array("qty"=>$qty,"price"=>$price);
- }
- }
1 check if session is set, if not set it then move to next if
2. if the product is in the cart, just add one to it, otherwise, add the product to the cart with a in the qty requested.
Can you see anything wrong there??
thanks in advance