$product) { if($product['id'] == $id) { unset($_SESSION['cart'][$key]); break; } } // Recalculate the cart total $_SESSION['cart_total'] = 0; foreach($_SESSION['cart'] as $product) { $_SESSION['cart_total'] += $product['price'] * $product['quantity']; } // Redirect back to the cart page echo ""; ?>