I have a problem with my code.
I don't understand this error:
Notice: Object of class stdClass could not be converted to int in C:\wamp\www\Site\include\fonction_panier.php on line 136
My line 136:
return $total + $total*$_SESSION['panier']['tva']/100;
This line is in this function:
function montantlGlobalTVA() {
$total = 0;
for ($i = 0; $i<count($_SESSION['panier']['libelleProduit']); $i++) {
$total += $_SESSION['panier']['qteProduit'][$i]*$_SESSION['panier']['prixProduit'][$i];
}
return $total + $total*$_SESSION['panier']['tva']/100;
}
TVA is in my database:
$select = $db->query("SELECT tva FROM produits");
$tva = $select->fetch(PDO::FETCH_OBJ);
$_SESSION['panier']['tva']= $tva;
When I do a var_dump()
:
<td><?php echo var_dump($_SESSION['panier']['tva'])." %";?></td>
I get this result:
object(stdClass)[1] public 'tva' => string '18' (length=2)