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’]))

JavaScript. forEach return an undefined

You need .some to check if any items in an array pass a test. forEach returns undefined: const data = [ {prop1: false, prop2: ‘someValue’}, {prop1: true, prop2: ‘someValue’}, {prop1: false, prop2: ‘someValue’} ] const isSomeProp1EqualToTrue = data.some(({ prop1 }) => prop1 === true); console.log(isSomeProp1EqualToTrue);