将具有“添加到购物车”功能的购物车放在一起。除了从购物车中删除物品外,一切正常。这是我所拥有的简化版本,以便更轻松地查看问题所在:
$action = $_GET['action'];
$id = $_GET['id'];
if ($action == "remove"){
unset($_SESSION['cart'][$product_id][$id]);
//Also tried this without sucess: $_SESSION['cart'][$product_id]--;
}
foreach($_SESSION['cart'] as $product_id) {
echo 'Details'.$product_id['title'].' - '.$product_id['price'];
echo '<a href="Cart.php?action=remove&id='.$product_id['product_id'].'">Remove</a>';
}