Guest User

Untitled

a guest
Jan 21st, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. <?php session_start();
  2.  
  3. $ref = $_GET['ajout'];
  4. //référence du produit choisi
  5.  
  6. if(isset($ref ))
  7. { //si $ref n'est pas vide
  8.  
  9. if(!isset($_SESSION['caddie']))
  10. { //si le caddie n'a pas été encore créé
  11.  
  12. $_SESSION['caddie'] = array(); //création de la variable de session
  13.  
  14. }
  15.  
  16.  
  17. if(isset($_SESSION['caddie'][$ref ]))
  18. { //si ce produit a déjà été choisi
  19.  
  20. $_SESSION['caddie'][$ref]++; //ajoute 1 a la quantité
  21.  
  22. }
  23. else
  24. {
  25.  
  26. $_SESSION['caddie'][$ref] = 1; //si 1er ajout, met la quantité à 1
  27.  
  28. }
Add Comment
Please, Sign In to add comment