I am looking for help for this problem that I have when I save my items that I add to the shopping cart, if I add several to the cart, it only saves me one and the price and the quantity keeps the total of everything I can do. I kept all the ids of the items and its the amount that corresponds to it and its price. I am new to this if you can explain to me in detail what I have to modify I would appreciate it.
$nombre = $this->input->post('nombre');
$apellido = $this->input->post('apellido');
$nueva_insercionCliente = $this->catalogo_model->insertarCliente($nombre,$apellido);
$idCliente = $this->db->insert_id();
$carrito = $this->cart->contents();
foreach ($carrito as $item) {
$idProducto = $item['id'];
if ($item['id'] == $idProducto) {
$cantidad = 1 + $item['qty'];
$total =$item['price'] * $cantidad;
}
}
$nueva_insercionPedido=$this->catalogo_model->insertarPedido($idProducto,$idCliente,$cantidad,$total);
redirect(base_url("catalogo"),"refresh");