PDA

View Full Version : Price adjustment in multiple pieces.



Yammaski
11-11-2012, 01:03 PM
I want to give a discount when the customer wants more than 2 of the same products.
The price shown must be the price minus the discount (see discounts on testpage).
There is also a "size option" which adjust the standard price of the product, this script works fine.
But my script for the discount doesn't work.

See testpage. (http://www.stickers.be/X_Tests/Prijs_Aantal/Prijs_Aantal.asp)




Files in zip.

vwphillips
11-12-2012, 01:53 PM
function getPrice(option, prodPrice) {
var prodPrice = parseFloat(prodPrice.replace(",","."));
var thePrice;
switch (option) {
case '10':
thePrice = (prodPrice-1).toFixed(2);
break;
case '15':
thePrice = prodPrice.toFixed(2);
break;
case '20':
thePrice = (prodPrice+2).toFixed(2);
break;
case '25':
thePrice = (prodPrice+4).toFixed(2);
break;
case '30':
thePrice = (prodPrice+5).toFixed(2);
break;
case '35':
thePrice = (prodPrice+6).toFixed(2);
break;
case '40':
thePrice = (prodPrice+7).toFixed(2);
break;
case '45':
thePrice = (prodPrice+8).toFixed(2);
break;
case '50':
thePrice = (prodPrice+9).toFixed(2);
break;
case '55':
thePrice = (prodPrice+10).toFixed(2);
break;
default:
thePrice = prodPrice.toFixed(2);
}
nu=document.getElementById('stickersBE_1_Quantity_Add').value;
thePrice=thePrice*nu;
if (nu>2){
if (nu<6){
thePrice-=thePrice/20;
}
if (nu<10){
thePrice-=thePrice/30;
}
else{
thePrice-=thePrice/25;
}
}
//DISCOUNT : 1-2 pcs : no discount *** 3-5 pcs : -20% *** 6-9 pcs : -30% *** > 10 pcs : -35%

return (thePrice.toFixed(2)+'').replace('.',',');
}

Yammaski
11-13-2012, 11:34 AM
thanks :)