Page 1 sur 1

réalisation d 'un panier d'achat!

Posté : 24 juin 2006, 09:30
par webmaster_ism_infomaster
:D Bonjour à tous je suis entrein de creer une boutique en ligne, là actuellement je buche sur la dernière étape le panier j ai deja fait un panier mais pour la cliente sà lui convient pas, normal car le nombre d articles est limité au nombre de 3 comment puis-je faire pour que la quantité soi sans limite (exemple le client aimerais commander 130 fair-part). :) Merci d'avance pour votre aide!

Posté : 24 juin 2006, 09:33
par Ben-J
qu'est qui te limite? donne nous un peu de code voire la structure de ta base etc... c'est souvent plus simple pour y trouver l'erreur, parce qu'on ne l'a pas développé, on ne peut rien savoir de ta façon de procéder ^^

Posté : 24 juin 2006, 09:38
par nejme.eddinne
Bonjour
utilisez les variables sessions()
exemple:
$_SESSION["id_prdcts"].="-".$produit["id_produit"];
a la fin pour extraire tous les id_produits:
$produits=explode("-",$_SESSION["id_prdcts"]);
vous aurez un tableau avec tous les "id" du produits.

ensuite tu peux extraire tous les informations relatives aux produits de ta base de données.
Essaye de voir des codes Open Source ca sera mieux.

re

Posté : 24 juin 2006, 10:01
par webmaster_ism_infomaster
Bonjour Ben-J je te m'ait la source d'ici 1H merci bc

re

Posté : 24 juin 2006, 10:27
par webmaster_ism_infomaster
voici le code souce du panier
<?php
session_start();
//init des variables
if (!isset($_SESSION['total'])) $_SESSION['total']=0;
if(!isset($_GET['ajoutPanier'])) $ajoutPanier="";//init de ajoutPanier si non déclaré
else  $ajoutPanier=$_GET['ajoutPanier']; 
if(!isset($_GET['modifPanier'])) $modifPanier="";//init de modifPanier si non déclaré
else $modifPanier=$_GET['modifPanier'];
if(!isset($_GET['suppPanier'])) $suppPanier="";//init de suppPanier si non déclaré
else $suppPanier=$_GET['suppPanier'];
if(!isset($_GET['enregistreCommande'])) $enregistreCommande="";//init de enregistreCommande si non déclaré
else $enregistreCommande=$_GET['enregistreCommande'];
if ((!isset($_SESSION['liste']))&&($ajoutPanier=="")) $liste[]=array("VIDE",1,0,0);//init de liste si VIDE
if (isset($_SESSION['liste'])) $liste=$_SESSION['liste'];//recup de la liste de la session
?>
<?php require_once('Connections/boutique.php'); ?>
<?php 
mysql_select_db($database_boutique, $boutique);
//----------------------------------------------------AJOUT PANIER
if ($ajoutPanier=="AJOUTER")
{
	$reference=$_GET['reference'];
	$nb=1; //par défaut la quantité est = 1
	$prix=$_GET['prix'];
	$liste[]=array($reference,$nb,$prix,$prix);
	$_SESSION['liste']=$liste;
	//ajoute un article à la liste
}
//----------------------------------------------------MODIF PANIER
if ($modifPanier=="ACTUALISER")
{
	 for ($i=0;$i<count($liste);$i++)
		{
		$nbi='nb'.$i;
		$liste[$i][1]=$_GET["$nbi"];//recup du nbr d'article dans la liste
		$liste[$i][3]=$liste[$i][1]*$liste[$i][2];//prixArticle=nbre*prixUnitaire
		}
	$_SESSION['liste']=$liste;//mAj de la liste
}
//----------------------------------------------------SUPP PANIER
if ($suppPanier=="SUPPRIMER")
{
	$article=$_GET['article'];
	for ($i=0;$i<count($liste);$i++)
		{
		if($article==$liste[$i][0])
			array_splice($liste,$i,1);
		//suppression de l'article
		}
	$_SESSION['liste']=$liste;//mAj de la liste
}
//----------------------------------------------------COMMANDER
if ($enregistreCommande=="COMMANDER")
{
	if(!isset($_GET['action'])) 
	$_SESSION['action']="ENREGISTRER";//mémorise l'action 
	header("Location: commande.php");
}
 ?>
et voici le code d affichage
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<!-- TemplateBeginEditable name="doctitle" -->
<title>histoiredimages.com: faire-part, album photos dvd, livre album, scrapbooking, retouche photo</title>
<!-- TemplateEndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="description" content="Artisan createur faire-part sur mesure, personnalise d'apres vos photographies, realisation d'albums photos sur DVD, mise en page de livres album photos, retouche photos.Animation atelier scrapbooking.">
<meta name="keywords" content="faire part, faire-part, faire, part, faire part naissance, sur mesure, personnalise, faire part mariage, voeux, scrapbooking, dvd, livre, album, atelier CE, scrap-booking, photos, scrap, booking, photo, 
photos, carte, pacs, invitation,  remerciement, menu, histoire, album photos dvd, montage photo, montage video, 
interactif, cd-rom, photographie, images, retouche photo, illustration, livre album photos,  livre album scrap, 
livre album photos scraps, bebe, carton d'invitation, scrapbook, faire part personnalise, faire-part personnalise, 
faire part photo, faire-part photos, scrap computer, scrapbooking computer, scrapbooking ordinateur, scrap ordinateur, 
faire part scrap, faire-part scrap, faire part personnalises">
<meta name="revisit-after" content="15 days">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="style_hdi.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
</head>
<body  bgcolor="#FFFFcc" background="Templates/images/jaune.jpg" leftmargin="0" topmargin="0" onLoad="MM_preloadImages('images/bt_accueilo.jpg', '/images/bt_serviceso.jpg','/images/bt_boutiqueo.jpg', '/images/bt_contacto.jpg','/images/bt_lienso.jpg','/images/bt_tarifso.jpg',
'/images/bt_carteso.jpg','/images/liens_faire-parto.jpg','images/liens_livrealbumo.jpg','/images/liens_albumdvdo.jpg','/images/liens_retouche.jpg','/images/liens_photoso.jpg','/images/liens_scrapo.jpg','/images/bt_partenaireo.jpg')">
<table width="100%"  border="0" cellpadding="0" cellspacing="0">
<tr>
<td><table width="100%"  border="0" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center">
<script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0','width','600','height','80','src','images/hdi','quality','high','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','images/hdi' ); //end AC code
</script>
<noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="600" height="80">
<param name="movie" value="images/hdi.swf">
<param name="quality" value="high">
<embed src="images/hdi.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="600" height="80"></embed>
</object></noscript>
</div></td>
</tr>
<tr>
<td height="106"><table width="100%"  border="0" cellpadding="0" cellspacing="0" background="images/bt-entre.jpg">
<tr>
<td width="22%"><img src="images/logo_hdimages.jpg" alt="faire-part, albums, livres album photos, retouche photos, scrapbooking" name="histoiredimages" width="203" height="103" id="histoiredimages" title="faire-part, albums, livres album photos, retouche photos, scrapbooking"></td>
<td width="13%"><a href="javascript:;" onMouseOver="MM_swapImage('acceuil','','images/bt_accueilo.jpg',1)" onMouseOut="MM_swapImgRestore()"><img src="images/bt_accueil.jpg" name="acceuil"  alt="faire-part, albums photos, livres album photos, retouche photos, scrapbooking" title="faire-part, albums photos, livres album photos, retouche photos, scrapbooking" width="110" height="103" border="0" id="acceuil"></a></td>
<td width="1%">&nbsp;</td>
<td width="1%">&nbsp;</td>
<td width="12%"><a href="javascript:;" onMouseOver="MM_swapImage('services','','images/bt_serviceso.jpg',1)" onMouseOut="MM_swapImgRestore()"><img src="images/bt_services.jpg" name="services" alt="faire-part, albums, livres album photos, retouche photos, scrapbooking" title="faire-part, albums, livres album photos, retouche photos, scrapbooking" width="107" height="103" border="0" id="services"></a></td>
<td width="1%">&nbsp;</td>
<td width="12%"><a href="javascript:;" onMouseOver="MM_swapImage('boutique','','images/bt_boutiqueo.jpg',1)" onMouseOut="MM_swapImgRestore()"><img src="images/bt_boutique.jpg" name="boutique" alt="modeles faire-part a personnaliser" title="modeles faire-part a personnaliser" width="108" height="103" border="0" id="boutique"></a></td>
<td width="1%">&nbsp;</td>
<td width="12%"><a href="javascript:;" onMouseOver="MM_swapImage('tarifs','','images/bt_tarifso.jpg',1)" onMouseOut="MM_swapImgRestore()"><img src="images/bt_tarifs.jpg" name="tarifs" width="109" height="103" border="0" id="tarifs"></a></td>
<td width="1%">&nbsp;</td>
<td width="12%"><a href="javascript:;" onMouseOver="MM_swapImage('contact','','images/bt_contacto.jpg',1)" onMouseOut="MM_swapImgRestore()"><img src="images/bt_contact.jpg" name="contact" width="110" height="103" border="0" id="contact"></a></td>
<td width="1%">&nbsp;</td>
<td width="11%"><img src="images/bt_bord.jpg" width="97" height="103" align="right"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td><table width="100%"  border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="25" align="left" valign="top"><table width="1%"  border="0" cellpadding="0" cellspacing="0">
<tr>
<td><a href="FairePart.php" onMouseOver="MM_swapImage('fairepart','','images/liens_faire-parto.jpg',1)" onMouseOut="MM_swapImgRestore()"><img src="images/liens_faire-part.jpg" name="fairepart" alt="modeles faire-part a personnaliser" title="modeles faire-part a personnaliser" width="200" height="60" border="0" id="fairepart"></a></td>
</tr>
<tr>
<td><a href="LivresAlbumPhotos.php" onMouseOver="MM_swapImage('livre','','images/liens_livrealbumo.jpg',1)" onMouseOut="MM_swapImgRestore()"><img src="images/liens_livrealbum.jpg" name="livrephoto" alt="livre album photos a personnaliser" title="livre album photos a personnaliser" width="200" height="60" border="0" id="livrephoto"></a></td>
</tr>
<tr>
<td><a href="AlbumPhotosDVD.php" onMouseOver="MM_swapImage('albumdvd','','images/liens_albumdvdo.jpg',1)" onMouseOut="MM_swapImgRestore()"></a></td>
</tr>
<tr>
<td><a href="RetouchePhotos.php" onMouseOver="MM_swapImage('retouche','','images/liens_retoucheo.jpg',1)" onMouseOut="MM_swapImgRestore()"><img src="images/liens_retouche.jpg" name="retouche" alt="retouche photos, restauration photo ancienne" title="retouche photos, restauration photo ancienne" width="200" height="60" border="0" id="retouche"></a></td>
</tr>
<tr>
<td><a href="Photographies.php" onMouseOver="MM_swapImage('photos1','','images/liens_photoso.jpg',1)" onMouseOut="MM_swapImgRestore()"><img src="images/liens_photos.jpg" name="photos1" alt="banque d'images, photographes" title="banque d'images, photographes" width="200" height="60" border="0" id="photos"></a></td>
</tr>
<tr>
<td><a href="Scrapbooking.php" onMouseOver="MM_swapImage('scrap','','images/liens_scrapo.jpg',1)" onMouseOut="MM_swapImgRestore()"><img src="images/liens_scrap.jpg" name="scrap" alt="ateliers scrapbooking " title="ateliers scrapbooking" width="200" height="60" border="0" id="scrap"></a></td>
</tr>
<tr>
<td><a href="javascript:;" onMouseOver="MM_swapImage('commande','','images/liens_scrapo.jpg',1)" onMouseOut="MM_swapImgRestore()"></a></td>
</tr>
</table></td>
<td width="100%"><table width="100%" height="100%"  border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="36" height="100%"><img src="images/cadre_hg.jpg" width="36" height="27"></td>
<td height="100%" background="images/cadre_h.jpg">&nbsp;</td>
<td width="28" height="100%"><img src="images/cadre_hd.jpg" width="28" height="27"></td>
</tr>
<tr>
<td width="36" height="100%" background="images/cadre_g.jpg">&nbsp;</td>
<td height="100%" background="images/cadre_fond.jpg"><!-- TemplateBeginEditable name="texte" -->
  <table width="100%" border="0">
    <tr>
      <td><div align="left">
          <p align="center"><img src="images/tex_accueil.jpg" width="474" height="69" align="texttop"></p>
          
            
                    <span class="accrochef">
<center>
  <table width="100%" border="0" cellspacing="0">
    <tr>
      <td><p align="center" class="accroche"><em>Votre panier</em></p>
          <?php if($liste[0][0]!="VIDE") { ?>
          <form action="Panier.php" method="get" >
            <table width="650" border="1" align="center" cellspacing="0" bordercolor="#FFCC66">
              <tr>
                <td><table width="650" border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr bgcolor="#FF0000">
                      <td width="200" bgcolor="#FFCC66"><div align="center"><font color="#FFFFFF"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Titre</font></strong></font></div></td>
                      <td width="200" bgcolor="#FFCC66"><div align="center"><font color="#FFFFFF"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Quantit&eacute;</font></strong></font></div></td>
                      <td width="200" bgcolor="#FFCC66"><div align="center"><font color="#FFFFFF"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Prix</font></strong></font></div></td>
                      <td width="50" bgcolor="#FFCC66"><div align="center"><font color="#FFFFFF"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Supp</font></strong></font></div></td>
                    </tr>
                    <?php
		   $total=0.00;
  for ($i=0;$i<count($liste);$i++)
{
	$query_rsPanier="select * from articlesfairepart where reference = '".$liste[$i][0]."'";
	//echo $query_rsPanier;
	$rsPanier = mysql_query($query_rsPanier, $boutique) or die(mysql_error());
    $row_rsPanier = mysql_fetch_assoc($rsPanier);		
	?>
                    <tr>
                      <td><div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><?php echo $row_rsPanier['titre'] ?></font></div></td>
                      <td><div align="center">
                          <select name="nb<?php echo $i ?>" id="nb">
                            <option value="1"  <?php if($liste[$i][1]==1) echo "SELECTED"; ?>>1</option>
                            <option value="2" <?php if($liste[$i][1]==2) echo "SELECTED"; ?>>2</option>
                            <option value="3" <?php if($liste[$i][1]==3) echo "SELECTED"; ?>>3</option>
                          </select>
                      </div></td>
                      <td><div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><?php echo $row_rsPanier['prix'] ?></font></div></td>
                      <td><div align="center"><a href="panier.php?suppPanier=SUPPRIMER&article=<?php echo $row_rsPanier['reference'] ?>"><img src="images/panier_retrait.jpg" width="24" height="20" border="0"></a></div></td>
                    </tr>
                    <?php
 	
	$total+=$row_rsPanier['prix'] * $liste[$i][1];
}
$_SESSION['total']=$total;//mAj du total dans la session

?>
                    <tr>
                      <td ><div align="center"></div></td>
                      <td ><div align="center"></div></td>
                      <td ><div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Total 
                        : <?php echo $total ?> Euros</strong></font></div></td>
                      <td ><div align="center"></div></td>
                    </tr>
                </table></td>
              </tr>
            </table>
            <br>
            <p align="center">
              <input type="submit" name="modifPanier" value="ACTUALISER">
              <input name="enregistreCommande" type="Submit" value="COMMANDER">
            </p>
          </form>
        <?php } else { ?>
          <p align="center"><strong><font size="4" face="Verdana, Arial, Helvetica, sans-serif">Votre panier est vide</font></strong></p>
        <?php }?>      </td>
    </tr>
  </table>
</center>
                                </span></div></td>
      </tr>
  </table>
<!-- TemplateEndEditable --><br></td>
<td width="28" height="100%" background="images/cadre_d.jpg">&nbsp;</td>
</tr>
<tr>
<td width="36" height="100%"><img src="images/cadre_bg.jpg" width="36" height="27"></td>
<td height="100%" background="images/cadre_b.jpg">&nbsp;</td>
<td width="28" height="100%"><img src="images/cadre_bd.jpg" width="28" height="27"></td>
</tr>
</table></td>
<td width="25%" align="left" valign="top"><table width="0%"  border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
</table>
  <table width="100%"  border="0">
    <tr>
      <td><a href="javascript:;" onMouseOver="MM_swapImage('partenaires','','images/bt_partenaireo.jpg',1)" onMouseOut="MM_swapImgRestore()"><img src="images/bt_partenaire.jpg" name="partenaires" alt="partenaires faire-part, retouche photos, photographes..." title="partenaires faire-part, retouche photos, photographes..." width="105" height="64" border="0" id="partenaires"></a></td>
    </tr>
    <tr>
      <td><a href="javascript:;" onMouseOver="MM_swapImage('ecartes','','images/bt_ecarteso.jpg',1)" onMouseOut="MM_swapImgRestore()"><img src="images/bt_ecartes.jpg" name="ecartes" alt="ecartes gratuites" title="ecartes gratuites" width="105" height="64" border="0" id="ecartes"></a></td>
    </tr>
    <tr>
      <td><a href="javascript:;" onMouseOver="MM_swapImage('liens','','images/bt_lienso.jpg',1)" onMouseOut="MM_swapImgRestore()"><img src="images/bt_liens.jpg" name="liens" alt="naissance, mariage, famille, photos, scrap" title="naissance, mariage, famille, photos, scrap" width="105" height="64" border="0" id="liens"></a></td>
    </tr>
  </table>  
  <!-- TemplateBeginEditable name="lienscommerciaux" -->
  <table width="108%" border="0">
    <tr>
      <td>&nbsp;</td>
    </tr>
  </table>
  <!-- TemplateEndEditable -->
  <table width="1%"  border="0">
    <tr>
      <td><img src="images/savoirfaire.jpg" width="115" height="124"></td>
    </tr>
  </table>  </td>
</tr>
</table></td>
</tr>
<tr>
<td><table width="100%"  border="0">
<tr>
<td background="images/bas.jpg">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>

Posté : 24 juin 2006, 11:08
par coxine
Bonjour
Ben je vois que dans le code d'affichage tu as un menu déroulant dans le formulaire qui doit correspondre à la quantité !
option value="1"  <?php if($liste[$i][1]==1) echo "SELECTED"; ?>>1</option> 
                            <option value="2" <?php if($liste[$i][1]==2) echo "SELECTED"; ?>>2</option> 
                            <option value="3" <?php if($liste[$i][1]==3) echo "SELECTED"; ?>>3</option>
Tu continues jusqu'à 130 ! :-D
Plus sérieusement, je ne connais pas son offre..mais qu'elle ce qu'elle vend 1 paquet de 100 faire part ?
ou un faire part à l'unité ?
Faut peut-être réfléchir de ce coté là avant de te lancer dans le script du panier.
Si elle vend un minimum de 100 faires part, la quantité "1" peut correspondre à 100 FP
Si le client veut en acheter 1000, ben il sélectionne 10*100
Ceci dit qu'est ce qui est affiché dans le catalogue comme offre ?????????
Si ce sont des paquets de 100 FP...et bien précisé, je ne vois pas où est ton pb !
:)

Ou sinon au lieu d'une liste déroulante qui te limite, tu mets un champ de formulaire, où la personne saisira à la mano la quantité souhaitée !
après, il faut faire le calcul
qte*prix unitaire....
Et si y a des dégressifs ? Comment vas tu les gérer ?
C'est pour ça que je t'invite plutôt à organiser ton catalogue par tranche de quantités prédéfinies ! Mais çà, est-ce que c'est ce que veut ta cliente ?

Posté : 24 juin 2006, 11:16
par Ben-J
ben coxine a été plus prompte... si tu veux vraiment procéder de cette façon, boucle le tout ^^ lol je pense en effet qu 'il faut que tu revoye quelques détails de conception, éventuellement avec ta cliente, pour savoir exactement ce qu'elle veut obtenir et comment

re

Posté : 24 juin 2006, 11:21
par webmaster_ism_infomaster
Merci bc coxine et Ben-J pour c est info car c est vraix que c est une étape que j ai mal étudier avec la cliente car c est mon premier site de Ecommerce, je contacte la cliente dans l apres midi et je vous tient au courant et encore merci pour votre aide

Posté : 24 juin 2006, 11:24
par coxine
de rien !
Effectivement, un catalogue de ecommerce doit être étudié (et je l'ai lu partout par des pros ici) sur le papier avant de se lancer dans le script !
Sinon ouille ouille !!! #-o
:lol:

Posté : 24 juin 2006, 11:41
par Ben-J
mais de rien
Si je puis me permettre, c'est comme dans n'importe quelle appli, vaut mieux savoir où on veut en venir avant de commencer ... ^^ (tu code bien l'html avant d'y inclure le php par exemple...)