1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| if (isset($_SESSION['panier']))//si la session existe et n'est pas nul
{ //on recupere le tableau en cession et on l'incremente avec les variables get/post
$nb = $_SESSION['nb'];
$panier = $_SESSION['panier'];
echo "<script>
alert ('Session existe !!');
</script>";
print_r($panier);
echo "</br>mon produit".$id_prod."</br>";
$trouve = array_search($id_prod,$panier);
echo $trouve;
if($trouve != NULL)//si le produit existe deja
{
echo "<script>
alert ('trouve !!');
</script>";
$tt_qte_com = $panier[$trouve+1] + $qte_command;
if($tt_qte_com <= $qte_stock['QUANTITE_PROD_STOCK'])//si la quantité général d'un produit doit etre <= au stock
{
$panier[$trouve+1] = $panier[$trouve+1] + $qte_command;
}
else//sinon on redirige
{
$selection = $qte_stock['QUANTITE_PROD_STOCK'] - $panier[$trouve+1];
if(isset($_GET['choix']))
{ $choix = mysql_real_escape_string($_GET['choix']); }
else
{ $choix = 0; }
$qte_prod_stock = $qte_stock['QUANTITE_PROD_STOCK'];
echo "<script>
alert ('Vous avez deja selectionné ".$panier[$trouve+1]." articles, et nous en avons que ".$qte_prod_stock." en stock. Vous pouvez selectionner que ".$selection." articles !! ');
document.location.href='acceuil.php?choix=".$choix."'
</script>";
}
} |
Partager