Mettre a jour la qte dans mon panier
maxuo0660
-
garf -
garf -
Bonjour,
Je souhaite realiser un panier dans lequel le client peut saisir le nombre de produit souhaite par defaut qte a comme valeur 1 pour dire qu'a l'ajout d'un article dans le panier la qte est egale a 1 mais lorsque le client clic sur afficher panier le panier s'affiche ex:
<?php
$quantite = $_GET['quantite'];
$total_prix='0';
$total='0';
$nb_produit =count($_SESSION['panier']['description']);
if ($nb_produit <= 0)
echo '<CAPTION> Panier </CAPTION>
<form action=\'panier_rafraichi.php?nb_article='.$nb_article.'&quantite='.$quantite.'\' method=\'post\'>
<table align=center border= 1 >
<tr><td width=200px>Description</td><td width=200px>Quantite</td><td width=200px>Prix</td><td>Sup</td></tr>
</table>
<table align=center border= 1 >
<tr><td>Votre panier est vide </td></tr>
</table>';
<CAPTION> Panier </CAPTION>
<form action=\'panier_rafraichi.php?nb_article='.$nb_article.'&quantite='.$quantite.'\' method=\'post\'>
<table align=center border= 1 >
<tr><td width=200px>Description</td><td width=200px>Quantite</td><td width=200px>Prix</td><td>Sup</td></tr>
</table>
<table align=center border= 1 >';
if ($nb_produit <= 0)
echo '<tr><td>Votre panier est vide </td></tr>';
else
{
for ($i=0 ;$i < $nb_produit ; $i++)
{
echo '<tr><td width=200px>'.htmlspecialchars($_SESSION['panier']['description'][$i]).'</td>
<td width=200px>
<select name='.$_SESSION['panier']['id_article'].'>
<option value="1">1';
for ($a=1 ;$a < $_SESSION['panier']['qte'][$i] ; $a++)
{
echo '<option value= '.$a.'> '.$a.'';
}
echo ' </select>';
$total_prix = $a*htmlspecialchars($_SESSION['panier']['prix'][$i]);
$total = $total + $total_prix;
echo '<td width=200px>'.$total_prix.'</td>
<td width=25px><a href="suppression_produit.php?nb_article='.$nb_article.'&quantite='.$quantite.'&prix= '.htmlspecialchars($_SESSION['panier']['prix'][$i]).'">X</a></td></tr>';
}
}
echo '<tr><td width=200px>Total</td><td width=200px></td><td width=200px>'.$total.'</td><td></td></tr>';
echo '</table>';
echo '<td width=200px><input type=\'submit\' value=\'Rafraichir\'></td>';
echo '</form>';
?>
voila mon code, donc je souhaite que le client puisse saisir la quantite qu'il souhaite pour l'article numero un, numero deux et enfin numero trois par ex. Que faire car lorsque que je modifie le 1er ou 2eme article rien ne se produit alors que lorsque je modifie le 3eme produit cela modifie les 3 articles. J'ai tourné le pb dans tous les sans mais je n'y arrive pas pouvez-vous m'indique la methode a suivre et ainsi que la syntaxe. Merci d'avance
Je souhaite realiser un panier dans lequel le client peut saisir le nombre de produit souhaite par defaut qte a comme valeur 1 pour dire qu'a l'ajout d'un article dans le panier la qte est egale a 1 mais lorsque le client clic sur afficher panier le panier s'affiche ex:
<?php
$quantite = $_GET['quantite'];
$total_prix='0';
$total='0';
$nb_produit =count($_SESSION['panier']['description']);
if ($nb_produit <= 0)
echo '<CAPTION> Panier </CAPTION>
<form action=\'panier_rafraichi.php?nb_article='.$nb_article.'&quantite='.$quantite.'\' method=\'post\'>
<table align=center border= 1 >
<tr><td width=200px>Description</td><td width=200px>Quantite</td><td width=200px>Prix</td><td>Sup</td></tr>
</table>
<table align=center border= 1 >
<tr><td>Votre panier est vide </td></tr>
</table>';
<CAPTION> Panier </CAPTION>
<form action=\'panier_rafraichi.php?nb_article='.$nb_article.'&quantite='.$quantite.'\' method=\'post\'>
<table align=center border= 1 >
<tr><td width=200px>Description</td><td width=200px>Quantite</td><td width=200px>Prix</td><td>Sup</td></tr>
</table>
<table align=center border= 1 >';
if ($nb_produit <= 0)
echo '<tr><td>Votre panier est vide </td></tr>';
else
{
for ($i=0 ;$i < $nb_produit ; $i++)
{
echo '<tr><td width=200px>'.htmlspecialchars($_SESSION['panier']['description'][$i]).'</td>
<td width=200px>
<select name='.$_SESSION['panier']['id_article'].'>
<option value="1">1';
for ($a=1 ;$a < $_SESSION['panier']['qte'][$i] ; $a++)
{
echo '<option value= '.$a.'> '.$a.'';
}
echo ' </select>';
$total_prix = $a*htmlspecialchars($_SESSION['panier']['prix'][$i]);
$total = $total + $total_prix;
echo '<td width=200px>'.$total_prix.'</td>
<td width=25px><a href="suppression_produit.php?nb_article='.$nb_article.'&quantite='.$quantite.'&prix= '.htmlspecialchars($_SESSION['panier']['prix'][$i]).'">X</a></td></tr>';
}
}
echo '<tr><td width=200px>Total</td><td width=200px></td><td width=200px>'.$total.'</td><td></td></tr>';
echo '</table>';
echo '<td width=200px><input type=\'submit\' value=\'Rafraichir\'></td>';
echo '</form>';
?>
voila mon code, donc je souhaite que le client puisse saisir la quantite qu'il souhaite pour l'article numero un, numero deux et enfin numero trois par ex. Que faire car lorsque que je modifie le 1er ou 2eme article rien ne se produit alors que lorsque je modifie le 3eme produit cela modifie les 3 articles. J'ai tourné le pb dans tous les sans mais je n'y arrive pas pouvez-vous m'indique la methode a suivre et ainsi que la syntaxe. Merci d'avance
A voir également:
- Mettre a jour la qte dans mon panier
- Mettre a jour chrome - Accueil - Applications & Logiciels
- Mettre a jour chromecast - Accueil - Guide TV et vidéo
- Mise a jour windows 10 - Accueil - Mise à jour
- Comment mettre à jour ses pilotes - Guide
- Mise à jour libre office - Accueil - Bureautique
1 réponse
personnellement j'utilise ce script de panier
http://www.webforcecart.com/
même si tu ne l'utilises pas tu pourras t'en inspirer
très simple et surtout fiable
http://www.webforcecart.com/
même si tu ne l'utilises pas tu pourras t'en inspirer
très simple et surtout fiable