Bonjour, je me présente christophe développeur web dans une agence de com et j'ai un gros soucis...
Voici le contexte, j'ai repris un projet de site de vente. On me demande de le debugger et d'y apporté des modifications. Et l'une de ces modifications se situe quand on passe commande... En gros mon soucis c'est qu'une personne arrive a passé commande sans rentrer d'adresse... Alors qu'il y a une sécu en js... Bon sa a l'air de passé a travers :/ Le site a été développé avec jelix 1.1.
voici les source:
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 $("#confirmation_button_com").click(function () { var panier_livraison = $("#confirmation_button_com").attr("numero_panier"); var adresse_livraison = $("#adresse_livraison").val(); adresse_livraison = jQuery.trim(adresse_livraison); var cp_livraison = $("#cp_livraison").val(); cp_livraison = jQuery.trim(cp_livraison); var ville_livraison = $("#ville_livraison").val(); ville_livraison = jQuery.trim(ville_livraison); var pays_livraison = $("#pays_livraison").val(); var telephone_livraison = $("#telephone_livraison").val(); telephone_livraison = jQuery.trim(telephone_livraison); var portable_livraison = $("#portable_livraison").val(); portable_livraison = jQuery.trim(portable_livraison); urlLivraison = jurl_portail_panier_updatelivraisonpanier; urlLivraison += "?numero_panier=" + panier_livraison + "&adresse=" + adresse_livraison + "&code_postal=" + cp_livraison + "&ville=" + ville_livraison + "&pays=" + pays_livraison + "&telephone=" + telephone_livraison + "&portable=" + portable_livraison; $.getJSON(urlLivraison, function (data1) { var success = data.success; if (success == 'false') { return false; } var adresseLivraisonPanier = data.adresseLivraisonPanier; $("#adresse_livraison").val(adresseLivraisonPanier.adresse); $("#cp_livraison").val(adresseLivraisonPanier.code_postal); $("#ville_livraison").val(adresseLivraisonPanier.ville); $("#pays_livraison").val(adresseLivraisonPanier.numero_pays); $("#telephone_livraison").val(adresseLivraisonPanier.telephone); $("#portable_livraison").val(adresseLivraisonPanier.portable); var recap_address = ""; recap_address += adresseLivraisonPanier.adresse + "<br />"; recap_address += adresseLivraisonPanier.code_postal + " "; recap_address += adresseLivraisonPanier.ville + "<br />"; recap_address += adresseLivraisonPanier.pays; $("#recap_address").empty(); $("#recap_address").append(recap_address); var panier_facturation = $("#confirmation_button_com").attr("numero_panier"); urlConfirmation = jurl_portail_panier_confirmerpanier; urlConfirmation += "?numero_panier=" + panier_facturation; $.getJSON(urlConfirmation, function (data) { if (data.ok == 0) { alert('Une erreur s\'est produite. La commande n\'a pas pu être totalement validée. Veuillez réessayer svp'); return false; } $("#etape_livraison").attr("style", "display:none"); $("#etape_confirmation").attr("style", "display:none");
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 function confirmerPanier() { $rep = $this->getResponse('json'); $commandes = array(); if (isset($_SESSION["panier"])) { $rDao = jDao::get("dressingenligne~panier"); foreach($_SESSION["panier"] as $k => $pan) { // Calcul total panier $listeProduit = Panier::listeProduitsDansPanier($pan['numero_panier']); $prix = 0; foreach($listeProduit as $produit) { if (count($produit["produit"]) > 0) { $prix+= $produit['produit']["prix"]; } } $prix = round($prix / 1.196, 2); $ret = Panier::confirmerPanier($pan["numero_panier"]); if ($ret === true) { $commandes[] = array( 'numcom' => date('ymd').'-'.$pan['numero_panier'], 'montant' => $prix ); unset($_SESSION['panier'][$k]); } } } $ok = 1; if (count($_SESSION['panier']) < 0) { $ok = 0; } $rep->data = array( 'ok' => $ok, 'commandes' => $commandes ); return $rep; }Merci d'avance pour votre aide ^^
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 function updateLivraisonPanier() { $rep = $this->getResponse('json'); $numero_panier = trim($this->param('numero_panier')); $adresse = trim($this->param('adresse')); $code_postal = trim($this->param('code_postal')); $ville = trim($this->param('ville')); $pays = trim($this->param('pays')); $telephone = trim($this->param('telephone')); $portable = trim($this->param('portable')); $ok = true; if (!$numero_panier || $numero_panier == '') { $ok = false; } if ($adresse == '' || $code_postal == '' || $ville == '' || $pays == '' || $telephone == '') { $ok = false; } if (!preg_match('/^\d+$/', $code_postal)) { $ok = false; } if (!preg_match('/^\d{10}$/', $telephone)) { $ok = false; } if ($ok !== true) { $rep->data = array('success' => 'false'); return $rep; } Panier::updateLivraisonPanier($numero_panier, $adresse, $code_postal, $ville, $pays, $telephone, $portable ); $adresseLivraisonPanier = Panier::getAdresseLivraisonPanier($numero_panier); //$_SESSION["adresseLivraison"] = $adresseLivraisonPanier; $rep->data = array("numero_panier"=>$numero_panier,"adresseLivraisonPanier"=>$adresseLivraisonPanier); return $rep; }
Christophe
Partager