Ciao a tutti,
devo applicare uno sconto dell' 8% ad un valore calcolato dinamicamente. Precisamente ad un carrello creato in actionscript.
Il codice è il seguente :
cartstatus = function() {
totalamount = 0;
totalshipping = 25;
totalitems = 0;
for (i=0; i<=selecteditems.length-1; i++) {
if (isNaN(selecteditems[i].attributes.shipping) == false) {
totalamount += (Number(selecteditems[i].attributes.price) * Number(selecteditems[i].attributes.quantity));
totalshipping += (Number(selecteditems[i].attributes.shipping) * Number(selecteditems[i].attributes.quantity));
} else {
totalamount += (Number(selecteditems[i].attributes.price) * Number(selecteditems[i].attributes.quantity));
}
totalitems += Number(selecteditems[i].attributes.quantity);
}
if (selecteditems.length == 0) {
btn.txt.text = "0 articoli";
} else {
if (totalshipping > 0) {
btn.txt.text = currencysymbol + String(totalamount) + " + " + currencysymbol + String(totalshipping) + " = " + currencysymbol + String(totalamount + totalshipping) + " " + String(totalitems) + " articoli";
} else {
btn.txt.text = currencysymbol + String(totalamount) + " " + String(totalitems) + " articoli";
}
}
}
cartstatus();
showmessagewin = function() {
hidemovie(messagewin);
messagewin = attachMovie("messagewindow", "messagewin" + String(getNextHighestDepth()), getNextHighestDepth());
showmovie(messagewin);
tip.swapDepths(getNextHighestDepth());
}
Lo sconto va applicato al totale del carrello prima dell'aggiunta delle spese di spedizioni (totalshipping)
C'è qualcuno che può darmi una mano?
Grazie anticipatamente a tutti