Warning: foreach staement
You need to have array in $_POST[‘quantity’] but you have something else, do var_dump($_POST[‘quantity’]); to see what inside $_POST[‘quantity’]. Also you can change if(!empty($_SESSION[‘cart’])) to if(!empty($_SESSION[‘cart’]) && is_array($_POST[‘quantity’]))