Clearly your product removal form submission is being offset by the fact your FORM action is also trying to re-add the product to your cart. Perhaps your easiest solution would be to add a switch to your FORM action like ?remove=1
which you can then check for before handling the case of buyproduct
, skipping that section entirely.
Note that this is not the cleanest solution, however, because you have uneccessary GET variables being sent to the server (mainly buyproduct
). A workaround for this could be for you to simply regenerate the query string for your form action:
// allowed keys is used to sanitize GET data by only allowing a predefined
// set of keys to be submitted with the form
$allowed_keys = array('page' => true, 'limit' => true, 'othervar' => true);
$str = 'path_to_form_action.php?';
foreach ($_GET as $k => $v) {
if (isset($allowed_keys[$k])) {
$str .= $k . '=' . $v . '&';
}
}
$str = substr($str, 0, -1);
You would then want to use $str
as your FORM action:
<form action="<?php echo $str; ?>" method="GET">