Whenever the shopping cart is empty, I open it and show the errors. But if I buy a product it disappears.
How do I resolve this?
Warning: Invalid argument supplied for foreach () in ... cart.php on line 152
foreach($_SESSION['monalisa_produto'] as $id => $qtd){
$total_frete_produtos += $_SESSION['valor_frete_'.$id]*$qtd;
}
Warning: Invalid argument supplied for foreach () in ... cart.php on line 93
foreach($_SESSION['monalisa_produto'] as $id => $qtd){
$_SESSION['valor_frete_'.$id] = str_replace(",",".",$_SESSION['valor_frete_'.$id]);
$_SESSION['valor_frete'] += $_SESSION['valor_frete_'.$id];
}
I saw a post that said to put a if
before foreach
, would it be correct?
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
....
}