bonjour, c'est mon premier message sur ce forum, alors j'espere que vous m'aiderez quand meme. J'utilise pour un site l'application javascript simpleCart.js que j'ai trouver sur notre amis google, bref, je fait un site marchand pour une entreprise de livraison qui livre des plats de restaurant a domicile ou au bureau, mon probleme c'est que j'ai besoin d'ajouter les frais de livraisons selon 2secteur et a chaque resto different, c'est a dire si une personne commande 4plats du meme resto c un seul frais soit 6.90 ou 10.00 selon secteur, mais si elle commande 2plats d'1 resto et 2 de l'autre c'est 2livraison puisque 2restos, voila je suis disposer a vous montrer tout ce que j'ai fait, a savoir qques bidouilles avec du php pour afficher les plats depuis une base de données et les ajouter au panier comme il faut, bref, si vous pouvez m'aider ca sera cool, merci. Extrait du onclick qui permet d'ajouter un plat: ...
','price=','image=','livraison=');return false;">Ajouter au panier ... et la totalité du script javascript qui l'interprete et l'ajoute au panier avant d'envoyer le tout sur paypal: ... function cart( email ) { this.totalItems = 0; this.totalPrice = 0.00; this.items = new Array(); this.userEmail = "haller.didier@gmail.com"; // order of columns, you change the order here or by accessing the value in your html this.ItemColumns = ['Image','Name','Price','Options','Quantity','Total']; /* function to initialize the cart when the page is loaded */ this.initialize = function () { if( !readCookie("simpleCart") ) { this.totalItems = 0; this.totalPrice = 0.00; } else { data = readCookie("simpleCart").split("&"); this.totalItems = data[0]*1; this.totalPrice = data[1]*1; for(x=2;x < (data.length);x++) { newItem = new item(); itemData = data[x].split(","); i=0; for(i=0;i'; } } else if ( this.ItemColumns[i] == 'Price' ) { tempCell.innerHTML = "P.U : " + this.returnFormattedPrice( tempItem.getValue('price')) + "¤"; } else if ( this.ItemColumns[i] == 'Quantity' ) { tempCell.innerHTML = "Quantité : " + '' + tempItem.getValue('quantity'); } else if ( this.ItemColumns[i] == 'Total' ) { tempCell.innerHTML = "Total : " + this.returnFormattedPrice( tempItem.getValue('quantity')* tempItem.getValue('price') ) + "¤"; } newRow.appendChild(tempCell); } newRow.className = "itemContainer" cartTable.appendChild(newRow); } } // create totals row if ( String(this.totalItems) == 0 ) { newRow = document.createElement('div'); tempCell = document.createElement('div'); tempCell.innerHTML = "
Votre Panier est Vide!
"; tempCell.className = "paniervide"; newRow.appendChild(tempCell); cartTable.appendChild(newRow); } else { newRow = document.createElement('div'); tempCell = document.createElement('div'); tempCell.innerHTML = "

" + String(this.totalItems) + " Article(s)"; tempCell.className = "totalItems"; newRow.appendChild(tempCell); tempCell = document.createElement('div'); tempCell.innerHTML = "Total : " + this.returnTotalPrice(); tempCell.className = "totalPrice"; newRow.appendChild(tempCell); newRow.className = "totalRow"; cartTable.appendChild(newRow); } return false; }; // return the cart total this.returnTotalPrice = function() { return this.returnFormattedPrice(this.totalPrice) + "¤"; }; // return a price with the format $xxx.xx this.returnFormattedPrice = function( price ) { temp = Math.round(price*100); change = String(temp%100); if( change.length == 0) { change = "00"; } else if( change.length == 1) { change = "0" + change; } temp = String(Math.floor(temp/100)); return temp + "." + change; }; this.updateQuantity = function() { newItem = new item(); x=0; for(x=0;x
< 1 ) { this.deleteItem( newItem ); return; } newQuan = new_quantity - newItem.getValue('quantity'); newItem.addValue('quantity', newQuan ); this.addItem(newItem); this.updateCookie(); this.updatePageElements(); return false; } // send user to paypal checkout with all the items in the cart this.checkOut = function() { if( this.totalItems == 0 ){ alert("Votre panier est vide!"); return false; } var winpar = "scrollbars,location,resizable,status"; var i,j=0,des,counter; var strn = "https://www.paypal.com/cgi-bin/webscr?cmd=_cart" + "&upload=1" + "&business=" + this.userEmail + "¤cy_code=EUR" + "&lc=FR"; counter = 0; for (counter = 0; counter < this.items.length; counter++) { tempItem = this.items[counter]; j = counter + 1; strn = strn + "&item_name_" + j + "=" + tempItem.getValue('name') + "&item_number_" + j + "=" + j + "&quantity_" + j + "=" + tempItem.getValue('quantity') + "&amount_" + j + "=" + this.returnFormattedPrice(tempItem.getValue('price') ) + "&shipping_" + j + "=" + tempItem.getValue('livraison') + "&no_note_" + j + "=" + "1"; if( tempItem.optionList() ) { strn = strn + "&on0_" + j + "=" + "Options" + "&os0_" + j + "=" + tempItem.optionList(); } } window.open (strn, "paypal", winpar); return false; }; } /************************************************************************************************* This is the item class. It will contain an array of name-value pairs. *************************************************************************************************/ function item () { this.names = new Array(); this.values = new Array(); /* add a name-value pair to the item, * return false and alert if the names * and values don't match. */ this.addValue = function(name,value) { if( this.names.length != this.values.length ) { alert("name and value array lengths do not match for this item!"); return false; } found = false; var a=0; for(a=0;a