|
Bonjour, tout d'abord votre site est vraiment excellent, voici mon probleme je n'arrive pas à calculer le prix total HT dans un pannier voici le code session:
<?php
session_start();
if (isset($_SESSION['panier']['nb_art'])) { // controle si un article existe deja dans le panier
$id_art_sel=$_SESSION['panier']['nb_art']+1; // numero de l'article qui sera ajout
} else {$id_art_sel=1;} // si il n'y a pas d'articles dj prsent
echo '<form name="form1" method="post" action="http://www.informatiques-consommables.com/commandes/panier.php">
<INPUT type="hidden" name="id_art" value="'.$id_art_sel.'">'; // pour passage de l'id article
?>
code du panier:
<?php
/* variables panier sous la forme :
$_SESSION['panier'][ID article][array(ref=>blabla,designation=>blabla,prixht=>blabla,quantite=>blabla);
*/
session_start();
if (isset($_POST['id_art'])) { // si il s'agit de l'ajout d'un article
$_SESSION['panier'][$_POST['id_art']]['ref'] = $_POST['ref'];
$_SESSION['panier'][$_POST['id_art']]['designation'] = $_POST['designation'];
$_SESSION['panier'][$_POST['id_art']]['prixht'] = $_POST['prixht'];
$_SESSION['panier'][$_POST['id_art']]['quantite'] = $_POST['quantite'];
}
$nb_art=count($_SESSION['panier']); // nombre d'articles dans le panier
if (count($_SESSION['panier']) > 0) { // si le panier n'est pas vide
echo'
<style type="text/css">
<!--
body,td,th {
color: #006699;
}
body {
background-image: url(../design/styles/fond.gif);
}
-->
</style>
<link href="../design/styles/styles.css" rel="stylesheet" type="text/css">
<table width="100%" border="1" borderstyle="color: #FFFFFF" bgstyle="color: #FFFFFF">
<tr borderstyle="color: #BDDFE1" bgstyle="color: #BDDFE1" class="menugauche">
<td width="25%">Reference</td>
<td width="25%" borderstyle="color: #BDDFE1">Description</td>
<td width="25%">Prix HT € </td>
<td width="25%">Quantité</td>
</tr>
</table>';
// affichage du contenu du panier
for ($i=1;$i <= $nb_art; $i++) { // pour chaque article du panier
echo '<table width="100%" border="1" borderstyle="color: #FFFFFF" bgstyle="color: #FFFFFF" >
<tr>
<td width="25%">'.$_SESSION['panier'][$i]['ref'].'</td>
<td width="25%">'.$_SESSION['panier'][$i]['designation'].'</td>
<td width="25%">'.$_SESSION['panier'][$i]['prixht'].'</td>
<td width="25%">'.$_SESSION['panier'][$i]['quantite'].'</td>
</tr>
</table>';
}
} else echo 'Votre panier ne contient aucun article.'; // le client n'a pas d'article dans son panier
?>
<style type="text/css">
<!--
.Style2 {color: #006699; font-weight: bold; font-size: 12px; font-family: Geneva, Arial, Helvetica, sans-serif; }
-->
</style>
<p> </p>
<table width="100%" border="1" borderstyle="color: #FFFFFF" bgstyle="color: FFFFFF" >
<tr>
<td bgstyle="color: #FFFFFF"><a href="javascript:history.go(-1)" class="Style2">Poursuivre ma Commande</a></td>
<td bgstyle="color: #FFFFFF"><p align="right"><a href="Formulaire1.php" target="_self" class="Style2">Valider ma Commande</a></p>
</td>
</tr>
</table>
<p> </p>
code du formulaire d'ajout d'articles:
PACK de 20 lecteurs de
disquettes 3.5 PCE 1.44MB
(coloris : beige)
0 1 2 3 4 5 6 7 8 9
url de demo:
http://www.informatiques-consommables.com/commandes/panier.php
en fait c le prix ht par la quantité qui me pose probleme,
merci |