IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

EDI, CMS, Outils, Scripts et API PHP Discussion :

modifs panier PHP


Sujet :

EDI, CMS, Outils, Scripts et API PHP

  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    253
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 253
    Par défaut modifs panier PHP
    Bonjour !

    J'ai adapter un code d'un panier PHP pour mon site, se trouvant à l'adresse suivante http://jcrozier.developpez.com/articles/web/panier/
    Pour ajouter des articles au panier, on se promène sur ma vitrine, on cloque sur "commander le produit" et il y a un lien de ce type :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    ../panier.php?action=ajout&l=NOMDUPRODUIT&q=1&p=PRIXTTC
    Une fois que l'on a cliqué sur COMMANDER, la page de panier s'ouvre, puis nous avons 2 choix : soit on fermer la fenetre à l'aide d'un bouton et on continu les achats, soit on termine la commande et la commande s'enregister dans un base de donnée.

    (Merci à ce créateur d'avoir fourni un code qui marche niquel ! )
    Mais je voudrais le modifier de la manière suivante :

    Je veux que tout soit étudié en fonction de la référence du produit.
    Donc je pense que l'URL donnera quelque chose de ce type :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    ../panier.php?action=ajout&r=REF_PRODUIT
    J'ai déjà mis en place ma base de données, en première colonne la reference, et apres le prix ht, prix ttc, libellé du produit, son poids, etc...
    J'ai également mon petit script en SQLqui va récuperer tous les champs de ce produit en fonction du numéro de référence, mais ma question est :
    Comment remplir ce panier en fonction de la REFERENCE svp ?
    J'ai rajouter des variables un peu partout, mais comme j'ai du ma encore avec tout ce PHP, j'ai tout fait bugué. (suppression et ajout d'articles ne marchent plus)

    Merci d'avance.

    Ju'

  2. #2
    Rédacteur
    Avatar de RideKick
    Homme Profil pro
    Directeur technique
    Inscrit en
    Septembre 2006
    Messages
    5 914
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Directeur technique
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Septembre 2006
    Messages : 5 914
    Par défaut
    Bonjour ,

    Au niveau du code , pas énormément de changement.

    Le panier ne doit contenir que le tableau s_SESSION["panier"]["ref"].

    Ensuite lors de l'affichage de celui ci , il faut aller chercher dans la base de données les autres informations liées à la référence : libelle , prix etc ...

    Poste le code on va le modifier ensemble si tu veux.
    Pas de questions techniques en MP please

    Mon site perso

    Mon profil Viadeo

  3. #3
    Membre confirmé
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    253
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 253
    Par défaut
    Bonjour,
    merci pour la réponse
    On va repartir du code d'origine, celui que j'ai modifié bug encore, surtout sur la modification du nombre d'articles et de la suppression des articles.

    Alors, le code de mon fichier panier.php :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
     
    <?php
    session_start();
    include_once("fonctions-panier.php");
    $erreur=false;
    $action="";
     
    if (isset($_GET['action']))
    {
    $erreur=false;
     if(in_array( $_GET['action'],array('ajout', 'suppression', 'refresh')))
      $action = $_GET['action'];
     
     else
      $erreur=true;
     
     $l = preg_replace('#\v#', '', $_GET['l']);
     
     $q = intval($_GET['q']);
     
     $p = floatval($_GET['p']);
     
     
    }
     
    elseif(isset($_POST['action']))
    {
     unset($_GET);
     $erreur=false;
     
     if(in_array($_POST['action'],array('ajout', 'suppression', 'refresh')))
      $action=$_POST['action'];
     else
      $erreur=true;
     
      $l = preg_replace('#\v#', '',$_POST['l']);
     
      $p = floatval($_POST['p']);
     
     
     $QteArticle = array();
     
     $i=0;
     foreach ($_POST['QteArticle'] as $contenu){
      $QteArticle[$i++] = intval($contenu);
     
     }
     
    }
     
     
     
     
    if ($erreur==false){
     
     switch($action){
     
      Case "ajout":
      ajouterArticle($l,$q,$p);
      break;
     
      Case "suppression":
      supprimerArticle($l);
      break;
     
      Case "refresh" :
     
      for ($i = 0 ; $i < count($QteArticle) ; $i++)
      {
        modifierQTeArticle($_SESSION['panier']['libelleProduit'][$i],round($QteArticle[$i]));
      }
      break;
     
      Default:
      break;
     
     }
    }
     
    ?> 
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr"> 
    <head>
    <title>Votre panier</title> <link rel="shortcut icon" href="../www.carri.com.lite_TEST2/favicon.ico"> 
    <meta name="verify-v1" content="C2J7hy08Xp2JmqfXIJIigFeU+8TutO1GZRu1K9rGEug=" /> 
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><meta NAME = 'ROBOTS' CONTENT = 'INDEX, FOLLOW'> 
    <STYLE type="text/css">
     
    BODY {
     
    scrollbar-face-color: #0066CC; 
     
    scrollbar-shadow-color: #000000;
     
    scrollbar-highlight-color: #FFFFFF;
     
    scrollbar-3dlight-color: #000000; 
     
    scrollbar-darkshadow-color: #000000; 
     
    scrollbar-track-color: #99CCFF; 
     
    scrollbar-arrow-color: #FF9900;
     
    }
     
    </STYLE> <link href="../www.carri.com.lite_TEST2/html/stylerol.css" rel="stylesheet" type="text/css"> 
    <script language="JavaScript">
    <!--
    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_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_findObj(n, d) { //v4.0
      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 && document.getElementById) x=document.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];}
    }
     
    function MM_displayStatusMsg(msgStr) { //v1.0
      status=msgStr;
      document.MM_returnValue = true;
    }
    //-->
    </script> 
    </head>
    <BODY BGCOLOR="#FFFFFF" ONLOAD="MM_preloadImages('../../Images/menu/Imprimer_on.jpg','Images/menu/Imprimer_on.jpg')">
    <TABLE BORDER="0" ALIGN="center" CELLPADDING="0" CELLSPACING="0" BGCOLOR="#FFFFFF" WIDTH="1000" HEIGHT="371"> 
    <TR> <TD COLSPAN="2" HEIGHT="83"><TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR BACKGROUND="../www.carri.com.lite_TEST2/images/menu/trait.gif"> 
    <TD WIDTH="419" HEIGHT="83" BACKGROUND="images/menu/trait.jpg" ALIGN="LEFT"><DIV ALIGN="LEFT"><IMG SRC="images/menu/carri_systems.gif" WIDTH="220" HEIGHT="83"></DIV></TD><TD VALIGN="BOTTOM" BACKGROUND="images/menu/trait.JPG" WIDTH="208"><DIV ALIGN="CENTER"><FONT COLOR="#FFFFFF" SIZE="3" FACE="Verdana, Arial, Helvetica, sans-serif"></FONT></DIV><TD WIDTH="632" HEIGHT="83" BACKGROUND="images/menu/trait.jpg" ALIGN="RIGHT"><DIV ALIGN="RIGHT"><IMG SRC="images/menu/systemes_infos_hp.gif" WIDTH="321" HEIGHT="83"></DIV></TD></TR></TABLE></TD></TR> 
    <TR><TD HEIGHT="251" COLSPAN="2" WIDTH="858" VALIGN="top"> <TABLE WIDTH="900" BORDER="0" CELLSPACING="0" CELLPADDING="0" HEIGHT="43%" ALIGN="CENTER"> 
    <TR> <TD VALIGN="TOP"><DIV ALIGN="CENTER"><P><FONT SIZE="2" FACE="Arial, Helvetica, sans-serif"><B><BR></B></FONT></P><TABLE WIDTH="800" BORDER="0" CELLSPACING="0" CELLPADDING="0" ALIGN="CENTER"><TR><TD><DIV ALIGN="CENTER"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><U><B><FONT COLOR="#0066CC" SIZE="4">COMMANDE</FONT></B></U></FONT></DIV></TD></TR></TABLE><P><FONT COLOR="#FFFFFF" SIZE="2" FACE="Verdana, Arial, Helvetica, sans-serif" CLASS="p1Copietitre"><A HREF="javascript:window.print()" ONMOUSEOUT="MM_swapImgRestore()" ONMOUSEOVER="MM_swapImage('Imprimer1','','Images/menu/Imprimer_on.jpg',1)"><IMG NAME="Imprimer1" BORDER="0" SRC="images/menu/Imprimer_off.jpg" WIDTH="130" HEIGHT="29" ONMOUSEOVER="MM_displayStatusMsg('Pour imprimer la page');return document.MM_returnValue" ALIGN="MIDDLE"></A></FONT> 
    <FORM METHOD="post" ACTION="panier.php"> <TABLE WIDTH="800" BORDER="0" CELLSPACING="0" CELLPADDING="0" HEIGHT="125" ALIGN="CENTER"><TR><TD><TABLE STYLE="width: 700px" WIDTH="700" HEIGHT="110" ALIGN="CENTER" BGCOLOR="#EEEEEE"> 
    <TR> <TD COLSPAN="4"><DIV ALIGN="CENTER"><P><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><B><FONT COLOR="ff0000" SIZE="3">VOTRE 
    PANIER </FONT></B></FONT></P><P>&nbsp;</P></DIV></TD ></TR> <TR VALIGN="TOP"> <TD WIDTH="369"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><B><U>Produits</U></B></FONT></TD><TD WIDTH="55"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><B><U>Quantité</U></B></FONT></TD><TD WIDTH="131"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><B><U>Prix 
    Unitaire TTC (&euro;)</U></B></FONT></TD><TD WIDTH="125"><P><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"></FONT></P></TD></TR> 
    <?php
    if (creationPanier())
    {
    $nbArticles=count($_SESSION['panier']['libelleProduit']);
      if ($nbArticles <= 0)
       echo "<tr><td>Votre panier est vide </ td></tr>";
      else
      {
       for ($i=0 ;$i < $nbArticles ; $i++)
       {
        echo "<tr>";
        echo "<td>".htmlspecialchars($_SESSION['panier']['libelleProduit'][$i])."</ td>";
        echo "<td><input type=\"text\" size=\"4\" name=\"QteArticle[]\" value=\"".htmlspecialchars($_SESSION['panier']['qteProduit'][$i])."\"/></td>";
        echo "<td>".htmlspecialchars($_SESSION['panier']['prixProduit'][$i])."</td>";
        echo "<td><a href=\"".htmlspecialchars("panier.php?action=suppression&l=".rawurlencode($_SESSION['panier']['libelleProduit'][$i]))."\">Supprimer article</a></td>";
        echo "</tr>";
       }
     
      echo "<tr><td colspan=\"2\"> </td>";
      echo "<td colspan=\"2\">";
      echo "<br><b>Total : ";
      echo sprintf('%.2f',MontantGlobal());
      echo " € ttc</b>";
      echo " | ";
    function prix_ttc($prix_ht,$taux_tva)
    {
               return ($prix_ht/(1+$taux_tva/100));
    }
     
    echo sprintf('%.2f',prix_ttc(MontantGlobal(),19.6)); 
    echo ' € ht';
      echo "</td></tr>";
     
      echo "<tr><td colspan=\"4\">";
      echo "<input type=\"submit\" value=\"Rafraichir\"/>";
      echo "<input type=\"hidden\" name=\"action\" value=\"refresh\"/>";
     
      echo "</td></tr>";
     
     }
     }
     
     
    ?> </TABLE></TD></TR></TABLE></FORM></DIV></TD></TR> </TABLE><TABLE WIDTH="100" BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR><TD> 
    </TD></TR></TABLE><TABLE WIDTH="525" BORDER="0" CELLSPACING="0" CELLPADDING="0" ALIGN="CENTER"><TR><TD WIDTH="50%"><DIV ALIGN="CENTER"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="3"><A HREF="javascript:window.close()"><I><B>Continuer 
    vos achats</B></I></A></FONT></DIV></TD><TD WIDTH="50%"><DIV ALIGN="CENTER"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="3"><A HREF="html/paiement/login.php" TARGET="_blank"><I><B>Terminer 
    votre commande</B></I></A></FONT></DIV></TD></TR></TABLE></TD></TR> </TABLE><DIV ALIGN="CENTER"></DIV>
    </body>
    </html>
    Au début, ce que j'ai fait :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
     
     $q = intval($_GET['q']);
     $r = $_GET['r'];						
     $connect=ODBC_connect("TESTPHP5","sa","sasa");
     $sql="select top 1 TYPE,DESIGNATION,CODETVA,PRIXHT,PRIXTTC,POIDS,HAUTEVALEUR from produits where CODEPRODUIT = '".$_GET['r']."' ";
     
     $res=odbc_exec($connect, $sql) or die($sql."<br />".odbc_error());
     $rs=odbc_fetch_row($res);
     $y= odbc_result($res,"TYPE");
     $l= odbc_result($res,"DESIGNATION");
     $t= odbc_result($res,"CODETVA");
     $h= odbc_result($res,"PRIXHT");
     $p= odbc_result($res,"PRIXTTC");
     $k= odbc_result($res,"POIDS");
     $v= odbc_result($res,"HAUTEVALEUR");
    Et mon URL pointant vers la page du panier pour commander :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    http://localhost/panier.php?action=ajout&r=121618&q=1
    Il vient rechercher la variable $r (reference) et $q (quantité, enfin ça, ça n'a pas changé)
    Et j'ai déjà créé un exemple d'articles dans la base.
    Pour essayer j'ai placé dans mon code :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     echo '[type='.$y.']';
     echo '[designation='.$l.']';
     echo '[code tva='.$t.']';
     echo '[prix HT='.$h.']';
     echo '[prix TTC='.$p.']';
     echo '[poids='.$k.']';
     echo '[haute valeur='.$v.']';
     echo '[quantité='.$q.']';
     echo '[code produit='.$r.']';
     echo '[quantite='.$q.']';
    Et ça m'affiche bien tout correctement (sauf quand je modifei le nombre ou quand je supprime.. ça m'efface tout)

    Merci

  4. #4
    Rédacteur
    Avatar de RideKick
    Homme Profil pro
    Directeur technique
    Inscrit en
    Septembre 2006
    Messages
    5 914
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Directeur technique
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Septembre 2006
    Messages : 5 914
    Par défaut
    Pour commencer on va modifier le panier et les fonctions qui vont avec :

    On va remplacer le libelle par la ref dans le panier , laisser la quantité et supprimer le prix.

    De sorte que tu ne stocke qu'en session une ref et sa quantité.

    Ensuite il faut modifier les fonctions ajouter , supprimer , modifierQuantite en conséquence. A savoir pour la fonction ajouter : ne laisser que ref et quantité. , supprimer devrait fonctionner car ça marchera directement sur la ref et modif aussi.

    Fait péter les codes si tu suis pas
    Pas de questions techniques en MP please

    Mon site perso

    Mon profil Viadeo

  5. #5
    Membre confirmé
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    253
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 253
    Par défaut
    Voilà, j'ai modifier ce que tu m'as demandé de faire, et mon ficheir panier.php donne ceci :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    <?php
    session_start();
    include_once("fonctions-panier.php");
    $erreur=false;
    $action="";
     
    if (isset($_GET['action']))
    {
    $erreur=false;
     if(in_array( $_GET['action'],array('ajout', 'suppression', 'refresh')))
      $action = $_GET['action'];
     
     else
      $erreur=true;
     
     
     
     
     $connect=ODBC_connect("TESTPHP5","sa","sasa");
     $sql="select top 1 TYPE,DESIGNATION,CODETVA,PRIXHT,PRIXTTC,POIDS,HAUTEVALEUR from produits where CODEPRODUIT = '".$_GET['r']."' ";
     $r = $_GET['r'];
     $q = intval($_GET['q']);
     $res=odbc_exec($connect, $sql) or die($sql."<br />".odbc_error());
     $rs=odbc_fetch_row($res);
     $y= odbc_result($res,"TYPE");
     $l= odbc_result($res,"DESIGNATION");
     $t= odbc_result($res,"CODETVA");
     $h= odbc_result($res,"PRIXHT");
     $p= odbc_result($res,"PRIXTTC");
     $k= odbc_result($res,"POIDS");
     $v= odbc_result($res,"HAUTEVALEUR");
     
    }
     
    elseif(isset($_POST['action']))
    {
     unset($_GET);
     $erreur=false;
     
     if(in_array($_POST['action'],array('ajout', 'suppression', 'refresh')))
      $action=$_POST['action'];
     else
      $erreur=true;
     
      $connect=ODBC_connect("TESTPHP5","sa","sasa");
      $sql="select top 1 TYPE,DESIGNATION,CODETVA,PRIXHT,PRIXTTC,POIDS,HAUTEVALEUR from produits where CODEPRODUIT = '".$_GET['r']."' ";
      $r = $r = $_POST['r'];
      $res=odbc_exec($connect, $sql) or die($sql."<br />".odbc_error());
      $rs=odbc_fetch_row($res);
      $y= odbc_result($res,"TYPE");
      $l= odbc_result($res,"DESIGNATION");
      $t= odbc_result($res,"CODETVA");
      $h= odbc_result($res,"PRIXHT");
      $p= odbc_result($res,"PRIXTTC");
      $k= odbc_result($res,"POIDS");
      $v= odbc_result($res,"HAUTEVALEUR");
     
     
     
     
     $QteArticle = array();
     
     $i=0;
     foreach ($_POST['QteArticle'] as $contenu){
      $QteArticle[$i++] = intval($contenu);
     
     }
     
    }
     
     
     
     
    if ($erreur==false){
     
     switch($action){
     
      Case "ajout":
      ajouterArticle($l,$q,$p);
      break;
     
      Case "suppression":
      supprimerArticle($l);
      break;
     
      Case "refresh" :
     
      for ($i = 0 ; $i < count($QteArticle) ; $i++)
      {
        modifierQTeArticle($_SESSION['panier']['codeProduit'][$i],round($QteArticle[$i]));
      }
      break;
     
      Default:
      break;
     
     }
    }
     
    ?> 
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr"> 
    <head>
    <title>Votre panier</title> <link rel="shortcut icon" href="../www.carri.com.lite_TEST2/favicon.ico"> 
    <meta name="verify-v1" content="C2J7hy08Xp2JmqfXIJIigFeU+8TutO1GZRu1K9rGEug=" /> 
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><meta NAME = 'ROBOTS' CONTENT = 'INDEX, FOLLOW'> 
    <STYLE type="text/css">
     
    BODY {
     
    scrollbar-face-color: #0066CC; 
     
    scrollbar-shadow-color: #000000;
     
    scrollbar-highlight-color: #FFFFFF;
     
    scrollbar-3dlight-color: #000000; 
     
    scrollbar-darkshadow-color: #000000; 
     
    scrollbar-track-color: #99CCFF; 
     
    scrollbar-arrow-color: #FF9900;
     
    }
     
    </STYLE> <link href="../www.carri.com.lite_TEST2/html/stylerol.css" rel="stylesheet" type="text/css"> 
    <script language="JavaScript">
    <!--
    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_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_findObj(n, d) { //v4.0
      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 && document.getElementById) x=document.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];}
    }
     
    function MM_displayStatusMsg(msgStr) { //v1.0
      status=msgStr;
      document.MM_returnValue = true;
    }
    //-->
    </script> 
    </head>
    <BODY BGCOLOR="#FFFFFF" ONLOAD="MM_preloadImages('../../Images/menu/Imprimer_on.jpg','Images/menu/Imprimer_on.jpg')">
    <TABLE BORDER="0" ALIGN="center" CELLPADDING="0" CELLSPACING="0" BGCOLOR="#FFFFFF" WIDTH="1000" HEIGHT="371"> 
    <TR> <TD COLSPAN="2" HEIGHT="83"><TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR BACKGROUND="../www.carri.com.lite_TEST2/images/menu/trait.gif"> 
    <TD WIDTH="419" HEIGHT="83" BACKGROUND="images/menu/trait.jpg" ALIGN="LEFT"><DIV ALIGN="LEFT"><IMG SRC="images/menu/carri_systems.gif" WIDTH="220" HEIGHT="83"></DIV></TD><TD VALIGN="BOTTOM" BACKGROUND="images/menu/trait.JPG" WIDTH="208"><DIV ALIGN="CENTER"><FONT COLOR="#FFFFFF" SIZE="3" FACE="Verdana, Arial, Helvetica, sans-serif"></FONT></DIV><TD WIDTH="632" HEIGHT="83" BACKGROUND="images/menu/trait.jpg" ALIGN="RIGHT"><DIV ALIGN="RIGHT"><IMG SRC="images/menu/systemes_infos_hp.gif" WIDTH="321" HEIGHT="83"></DIV></TD></TR></TABLE></TD></TR> 
    <TR><TD HEIGHT="251" COLSPAN="2" WIDTH="858" VALIGN="top"> <TABLE WIDTH="900" BORDER="0" CELLSPACING="0" CELLPADDING="0" HEIGHT="43%" ALIGN="CENTER"> 
    <TR> <TD VALIGN="TOP"><DIV ALIGN="CENTER"><P><FONT SIZE="2" FACE="Arial, Helvetica, sans-serif"><B><BR></B></FONT></P><TABLE WIDTH="800" BORDER="0" CELLSPACING="0" CELLPADDING="0" ALIGN="CENTER"><TR><TD><DIV ALIGN="CENTER"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><U><B><FONT COLOR="#0066CC" SIZE="4">COMMANDE</FONT></B></U></FONT></DIV></TD></TR></TABLE><P><FONT COLOR="#FFFFFF" SIZE="2" FACE="Verdana, Arial, Helvetica, sans-serif" CLASS="p1Copietitre"><A HREF="javascript:window.print()" ONMOUSEOUT="MM_swapImgRestore()" ONMOUSEOVER="MM_swapImage('Imprimer1','','Images/menu/Imprimer_on.jpg',1)"><IMG NAME="Imprimer1" BORDER="0" SRC="images/menu/Imprimer_off.jpg" WIDTH="130" HEIGHT="29" ONMOUSEOVER="MM_displayStatusMsg('Pour imprimer la page');return document.MM_returnValue" ALIGN="MIDDLE"></A></FONT> 
    <FORM METHOD="post" ACTION="panier.php"> <TABLE WIDTH="800" BORDER="0" CELLSPACING="0" CELLPADDING="0" HEIGHT="125" ALIGN="CENTER"><TR><TD><TABLE STYLE="width: 700px" WIDTH="700" HEIGHT="110" ALIGN="CENTER" BGCOLOR="#EEEEEE"> 
    <TR> <TD COLSPAN="4"><DIV ALIGN="CENTER"><P><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><B><FONT COLOR="ff0000" SIZE="3">VOTRE 
    PANIER </FONT></B></FONT></P><P>&nbsp;</P></DIV></TD ></TR> <TR VALIGN="TOP"> <TD WIDTH="369"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><B><U>Produits</U></B></FONT></TD><TD WIDTH="55"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><B><U>Quantité</U></B></FONT></TD><TD WIDTH="131"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><B><U>Prix 
    Unitaire TTC (&euro;)</U></B></FONT></TD><TD WIDTH="125"><P><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"></FONT></P></TD></TR> 
    <?php
    if (creationPanier())
    {
    $nbArticles=count($_SESSION['panier']['codeProduit']);
      if ($nbArticles <= 0)
       echo "<tr><td>Votre panier est vide </ td></tr>";
      else
      {
       for ($i=0 ;$i < $nbArticles ; $i++)
       {
        echo "<tr>";
        echo "<td>".htmlspecialchars($_SESSION['panier']['codeProduit'][$i])."</ td>";
        echo "<td><input type=\"text\" size=\"4\" name=\"QteArticle[]\" value=\"".htmlspecialchars($_SESSION['panier']['qteProduit'][$i])."\"/></td>";
        echo "<td>".htmlspecialchars($_SESSION['panier']['prixProduit'][$i])."</td>";
        echo "<td><a href=\"".htmlspecialchars("panier.php?action=suppression&l=".rawurlencode($_SESSION['panier']['codeProduit'][$i]))."\">Supprimer article</a></td>";
        echo "</tr>";
       }
     
      echo "<tr><td colspan=\"2\"> </td>";
      echo "<td colspan=\"2\">";
      echo "<br><b>Total : ";
      echo sprintf('%.2f',MontantGlobal());
      echo " € ttc</b>";
      echo " | ";
    function prix_ttc($prix_ht,$taux_tva)
    {
               return ($prix_ht/(1+$taux_tva/100));
    }
     
    echo sprintf('%.2f',prix_ttc(MontantGlobal(),19.6)); 
    echo ' € ht';
      echo "</td></tr>";
     
      echo "<tr><td colspan=\"4\">";
      echo "<input type=\"submit\" value=\"Rafraichir\"/>";
      echo "<input type=\"hidden\" name=\"action\" value=\"refresh\"/>";
     
      echo "</td></tr>";
     
     }
     }
     
     
    ?> </TABLE></TD></TR></TABLE></FORM></DIV></TD></TR> </TABLE><TABLE WIDTH="100" BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR><TD> 
    </TD></TR></TABLE><TABLE WIDTH="525" BORDER="0" CELLSPACING="0" CELLPADDING="0" ALIGN="CENTER"><TR><TD WIDTH="50%"><DIV ALIGN="CENTER"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="3"><A HREF="javascript:window.close()"><I><B>Continuer 
    vos achats</B></I></A></FONT></DIV></TD><TD WIDTH="50%"><DIV ALIGN="CENTER"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="3"><A HREF="html/paiement/login.php" TARGET="_blank"><I><B>Terminer 
    votre commande</B></I></A></FONT></DIV></TD></TR></TABLE></TD></TR> </TABLE><DIV ALIGN="CENTER"></DIV>
    </body>
    </html>
    et fonction-panier.php donne ceci :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    <?php
    function creationPanier(){
    $ret=false;
     
    if (isset( $_SESSION['panier']))
     $ret = true;
    else
    {
     
      $_SESSION['panier']=array();
      $_SESSION['panier']['codeProduit'] = array();
      $_SESSION['panier']['qteProduit'] = array();      
     
      $ret=true;
    }
    return $ret;
    }
     
    function ajouterArticle($codeProduit,$qteProduit){
     
    if (creationPanier())
    {
    $positionProduit = array_search($codeProduit,  $_SESSION['panier']['codeProduit']);
     
      if ($positionProduit !== false)
      {
       $_SESSION['panier']['qteProduit'][$positionProduit] += $qteProduit ;
      }
      else
      {
       array_push( $_SESSION['panier']['codeProduit'],$codeProduit);
       array_push( $_SESSION['panier']['qteProduit'],$qteProduit); 
     
      }
     
    }
     
    else
      echo "Un problème est survenu veuillez contacter l'administrateur du site.";
    }
     
    function supprimerArticle($codeProduit){
     
    if (creationPanier())
    {
      $tmp=array();
      $tmp['codeProduit'] = array();
      $tmp['qteProduit'] = array();      
     
     
      for($i = 0; $i < count($_SESSION['panier']['codeProduit']); $i++) 
      {
       if ($_SESSION['panier']['codeProduit'][$i] !== $codeProduit)
       {
        array_push( $tmp['codeProduit'],$_SESSION['panier']['codeProduit'][$i]);
        array_push( $tmp['qteProduit'],$_SESSION['panier']['qteProduit'][$i]); 
     
       }
     
      }
     
     
    $_SESSION['panier'] =  $tmp;
    unset($tmp);      
     
    }
    else
      echo "Un problème est survenu veuillez contacter l'administrateur du site.";
    }
     
    function modifierQTeArticle($codeProduit,$qteProduit){
    if (creationPanier())
    {
     
      if ($qteProduit > 0)
      {
       $positionProduit = array_search($codeProduit,  $_SESSION['panier']['codeProduit']);
     
       if ($positionProduit !== false)
       {
        $_SESSION['panier']['qteProduit'][$positionProduit] = $qteProduit ;
       }
      }
      else
       supprimerArticle($codeProduit);
     
    }
    else
      echo "Un problème est survenu veuillez contacter l'administrateur du site.";
    }
     
    function MontantGlobal(){
     
    $total=0;
     
      for($i = 0; $i < count($_SESSION['panier']['codeProduit']); $i++) 
      {            
       $total += $_SESSION['panier']['qteProduit'][$i] * $_SESSION['panier']['prixProduit'][$i]; 
      }
     
    return $total;
    }
     
    ?>
    Mais je pense que déjà j'ai un probleme concernant la fonction suivante :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    function MontantGlobal(){
     
    $total=0;
     
      for($i = 0; $i < count($_SESSION['panier']['codeProduit']); $i++) 
      {            
       $total += $_SESSION['panier']['qteProduit'][$i] * $_SESSION['panier']['prixProduit'][$i]; 
      }
     
    return $total;
    }
    Car il s'agit maintenant de prix HT enregistrés dans la base (la TVA sera calculée automatiquement en fonction d'un code TVA)

  6. #6
    Rédacteur
    Avatar de RideKick
    Homme Profil pro
    Directeur technique
    Inscrit en
    Septembre 2006
    Messages
    5 914
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Directeur technique
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Septembre 2006
    Messages : 5 914
    Par défaut
    Bon , les modifs sont bonnes , effectivement, la fonction montant global ne va plus marcher comme ceci , on la modifiera par la suite .

    Est-ce que en l'état maintenant ton script marche ? (Après avoir impacté tes modifs dans le reste du script)
    Pas de questions techniques en MP please

    Mon site perso

    Mon profil Viadeo

  7. #7
    Membre confirmé
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    253
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 253
    Par défaut
    j'avais encore 1 element en mémoire dans la session, j'ai pu le supprimer sans aucun probleme. Par contre quand je veux rajouter un element au panier cela ne me rajoute rien (pas d'erreur spécifiée)

  8. #8
    Rédacteur
    Avatar de RideKick
    Homme Profil pro
    Directeur technique
    Inscrit en
    Septembre 2006
    Messages
    5 914
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Directeur technique
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Septembre 2006
    Messages : 5 914
    Par défaut
    la ligne ici est fausse :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     Case "ajout":
      ajouterArticle($l,$q,$p);
      break;
    puisque ajouterArticle() ne prends a présent que 2 valeurs. la ref et la quantité.
    Pas de questions techniques en MP please

    Mon site perso

    Mon profil Viadeo

  9. #9
    Membre confirmé
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    253
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 253
    Par défaut
    bon, j'ai compilé, et ça ma mis cette erreur là :

    Warning: Missing argument 3 for ajouterArticle(), called in C:\Programmes\wampserver2.0c\www\panier.php on line 79 and defined in C:\Programmes\wampserver2.0c\www\fonctions-panier.php on line 19

    la ligne 79 de panier.php appartient à un IF :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    if ($erreur==false){
    
     switch($action){
    
      Case "ajout":
      ajouterArticle($r,$q);
      break;
    
      Case "suppression":
      supprimerArticle($r);
      break;
    
      Case "refresh" :
    
      for ($i = 0 ; $i < count($QteArticle) ; $i++)
      {
        modifierQTeArticle($_SESSION['panier']['codeProduit'][$i],round($QteArticle[$i]));
      }
      break;
    
      Default:
      break;
          
     }
    }
    et la ligne 19 appartient a la fonction ajouterarticle
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    function ajouterArticle($codeProduit,$qteProduit){
    
    if (creationPanier())
    {
    $positionProduit = array_search($codeProduit,  $_SESSION['panier']['codeProduit']);
    	
      if ($positionProduit !== false)
      {
       $_SESSION['panier']['qteProduit'][$positionProduit] += $qteProduit ;
      }
      else
      {
       array_push( $_SESSION['panier']['codeProduit'],$codeProduit);
       array_push( $_SESSION['panier']['qteProduit'],$qteProduit); 
    
      }
    
    }

  10. #10
    Rédacteur
    Avatar de RideKick
    Homme Profil pro
    Directeur technique
    Inscrit en
    Septembre 2006
    Messages
    5 914
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Directeur technique
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Septembre 2006
    Messages : 5 914
    Par défaut
    Citation Envoyé par RideKick Voir le message
    la ligne ici est fausse :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     Case "ajout":
      ajouterArticle($l,$q,$p);
      break;
    puisque ajouterArticle() ne prends a présent que 2 valeurs. la ref et la quantité.
    Pas de questions techniques en MP please

    Mon site perso

    Mon profil Viadeo

  11. #11
    Membre confirmé
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    253
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 253
    Par défaut
    oui oui dans le code que j'ai copier/coller recemment j'ai bien mis

  12. #12
    Membre confirmé
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    253
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 253
    Par défaut
    Arf j'avais du oublier d'enregistrer un fichier txt, car mintenant que c'est fait j'ai ceci :
    Warning: array_search() [function.array-search]: Wrong datatype for second argument in C:\Programmes\wampserver2.0c\www\fonctions-panier.php on line 23

    Warning: array_push() [function.array-push]: First argument should be an array in C:\Programmes\wampserver2.0c\www\fonctions-panier.php on line 31


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    if (isset( $_SESSION['panier']))
     $ret = true;
    else
    {
    
      $_SESSION['panier']=array();
      $_SESSION['panier']['codeProduit'] = array();
      $_SESSION['panier']['qteProduit'] = array();      
    
      $ret=true;
    }
    return $ret;
    }
    
    function ajouterArticle($codeProduit,$qteProduit){
    
    if (creationPanier())
    {
    $positionProduit = array_search($codeProduit,  $_SESSION['panier']['codeProduit']);
    	
      if ($positionProduit !== false)
      {
       $_SESSION['panier']['qteProduit'][$positionProduit] += $qteProduit ;
      }
      else
      {
       array_push( $_SESSION['panier']['codeProduit'],$codeProduit);
       array_push( $_SESSION['panier']['qteProduit'],$qteProduit); 
    
      }
    
    }

  13. #13
    Rédacteur
    Avatar de RideKick
    Homme Profil pro
    Directeur technique
    Inscrit en
    Septembre 2006
    Messages
    5 914
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Directeur technique
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Septembre 2006
    Messages : 5 914
    Par défaut
    Ton $_SESSION["panier"] doit être corrompu , détruit ta session avant de reexecuter le code.
    Pas de questions techniques en MP please

    Mon site perso

    Mon profil Viadeo

  14. #14
    Membre confirmé
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    253
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 253
    Par défaut
    Effectivement, dans mon compteur en haut de page ya marqué "32 articles dans le panier" et ça s'inscrémente bien quand je recharge la page.

    Bon j'ai détruit ma session, et là effectivement je n'ai plus d'erreurs. (quand j'ajoute un produit)

    L'outil suppression ne marche pas, il ne me supprime que le libellé, et non la ligne.

  15. #15
    Rédacteur
    Avatar de RideKick
    Homme Profil pro
    Directeur technique
    Inscrit en
    Septembre 2006
    Messages
    5 914
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Directeur technique
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Septembre 2006
    Messages : 5 914
    Par défaut
    tu peux mettre le code de ta fonction supprimer() stp ?
    Pas de questions techniques en MP please

    Mon site perso

    Mon profil Viadeo

  16. #16
    Membre confirmé
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    253
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 253
    Par défaut
    Cela supprime quand je force le nombre d'articles à 0

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    function supprimerArticle($codeProduit){
     
    if (creationPanier())
    {
      $tmp=array();
      $tmp['codeProduit'] = array();
      $tmp['qteProduit'] = array();      
     
     
      for($i = 0; $i < count($_SESSION['panier']['codeProduit']); $i++) 
      {
       if ($_SESSION['panier']['codeProduit'][$i] !== $codeProduit)
       {
        array_push( $tmp['codeProduit'],$_SESSION['panier']['codeProduit'][$i]);
        array_push( $tmp['qteProduit'],$_SESSION['panier']['qteProduit'][$i]); 
     
       }
     
      }
     
     
    $_SESSION['panier'] =  $tmp;
    unset($tmp);      
     
    }
    else
      echo "Un problème est survenu veuillez contacter l'administrateur du site.";
    }

  17. #17
    Rédacteur
    Avatar de RideKick
    Homme Profil pro
    Directeur technique
    Inscrit en
    Septembre 2006
    Messages
    5 914
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Directeur technique
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Septembre 2006
    Messages : 5 914
    Par défaut
    Citation Envoyé par ju0123456789 Voir le message
    Cela supprime quand je force le nombre d'articles à 0

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    function supprimerArticle($codeProduit){
     
    if (creationPanier())
    {
      $tmp=array();
      $tmp['codeProduit'] = array();
      $tmp['qteProduit'] = array();      
     
     
      for($i = 0; $i < count($_SESSION['panier']['codeProduit']); $i++) 
      {
       if ($_SESSION['panier']['codeProduit'][$i] !== $codeProduit)
       {
        array_push( $tmp['codeProduit'],$_SESSION['panier']['codeProduit'][$i]);
        array_push( $tmp['qteProduit'],$_SESSION['panier']['qteProduit'][$i]); 
     
       }
     
      }
     
     
    $_SESSION['panier'] =  $tmp;
    unset($tmp);      
     
    }
    else
      echo "Un problème est survenu veuillez contacter l'administrateur du site.";
    }
    tu veux dire dans le panier html ? si c'est le cas oi , c'est en mettant 0 qu'on supprime des articles.
    Pas de questions techniques en MP please

    Mon site perso

    Mon profil Viadeo

  18. #18
    Membre confirmé
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    253
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 253
    Par défaut
    oui mais le coté pratique de ta fonction de suppression, c'est de pouvoir supprimer l'article que l'on veut avec le lien "supprimer articles" qui ne fonctionne pas pour le moment

  19. #19
    Rédacteur
    Avatar de RideKick
    Homme Profil pro
    Directeur technique
    Inscrit en
    Septembre 2006
    Messages
    5 914
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Directeur technique
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Septembre 2006
    Messages : 5 914
    Par défaut
    et comment tu gère la suppression ? (lien , code etc )
    Pas de questions techniques en MP please

    Mon site perso

    Mon profil Viadeo

  20. #20
    Membre confirmé
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    253
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 253
    Par défaut
    a oui, et aussi, j'affiche la reference du produit, la quantite dans un input modifiable, le prix unitaire (que je vais chercher dans la base en fonction de la reference) et pareil pour le libelle.
    Quand je modifie le nombre d'articles, le libelle et le prix unitaire disparaissent... (meme symptome quand je clique sur "supprimer articles"

    Bah le code de la suppression je te l'ai envoyée au dessus, et le lien c'est :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
        echo "<td><a href=\"".htmlspecialchars("panier.php?action=suppression&l=".rawurlencode($_SESSION['panier']['codeProduit'][$i]))."\">Supprimer article</a></td>";

Discussions similaires

  1. [Mail] panier php à envoyer par mail
    Par bijouxenbois dans le forum Langage
    Réponses: 19
    Dernier message: 11/04/2008, 22h38
  2. Modification de php.ini
    Par skysee dans le forum GTK+ avec PHP
    Réponses: 2
    Dernier message: 12/12/2007, 23h07
  3. Gestion panier PHP - Explorer/Firefox
    Par len73 dans le forum Langage
    Réponses: 6
    Dernier message: 13/05/2007, 18h52
  4. [MySQL] Modification avec php
    Par stan30160 dans le forum PHP & Base de données
    Réponses: 27
    Dernier message: 02/03/2007, 16h29
  5. Réponses: 20
    Dernier message: 02/06/2006, 12h13

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo