Hier het script:
switch($action) { //decide what to do
case "add":
$_SESSION['cart'][$product_id]['quant']++;
break;
case "remove":
$_SESSION['cart'][$product_id]['quant']--;
if ($_SESSION['cart'][$product_id]['quant'] == 0) unset($_SESSION['cart'][$product_id]); //if the quantity is zero, remove it completely (using the 'unset' function) - otherwise is will show zero, then -1, -2 etc when the user keeps removing items.
break;
case "empty":
unset($_SESSION['cart']); //unset the whole cart, i.e. empty the cart.
break; }
De link waar men op klikt:
[code]
<a class="button" href="webshop.php?action=add&product_id=<? echo $row->id; ?>">Bestel</a>
[code]
En om 1 van het artikel te verwijderen:
[code]
<a class="button" href="webshop.php?action=remove&product_id=<? echo $row->id; ?>">Bestel</a>
[code]
En dan nog een linkje voor het leeggooien van de winkelwagen, de empty, maar dat spreekt voor zich.
Kunnen jullie mij vertellen wat er mis gaat?