<% Sub CalculateDiscount (subtotal, total, shippingcost, discpercent, discount) dim tdiscpercent '********************************************************** ' This routine calculates Discouns over total order fo VP-ASP ' Inputs are ' subtotal - price of of products order ' total - price including shipping ' shippingcost cost of shipping ' discount this value needs to be set and returned ' discpercent is from customer record ' Version 6.50 Jan 9, 2003 ' xdiscountamount is lower limit ' xdiscountpercent is percentage or amount '************************************************************* tdiscpercent=discpercent if tdiscpercent=""then tdiscpercent=0 end if if tdiscpercent=0 then if getconfig("xdiscountamount")<>"" then discountbyamount subtotal, total, shippingcost, discpercent, discount exit sub end if exit sub end if if not isnumeric(discpercent) then exit sub ' if greater than 1 it is not a percent If discpercent > 1 then discount= discpercent exit sub end if discount=subtotal*discpercent end sub ' Sub discountbyamount (subtotal, total, shippingcost, discpercent, discount) dim orderlimit, percent, percentamount, testamount dim limits(50),limitcount, percents(60),percentcount,i dim delimiter, pos dim lowlimit, highlimit, lowrange, highrange orderlimit=getconfig("xdiscountlimit") pos=instr(orderlimit,";") if pos>0 then delimiter=";" else delimiter="," end if percent=getconfig("xdiscountamount") parserecord orderlimit, limits, limitcount,delimiter parserecord percent, percents, percentcount,delimiter lowlimit=csng(limits(0)) limitcount=limitcount-1 highlimit=csng(limits(limitcount)) If subtotal < lowlimit then exit sub If subtotal>highlimit then percentamount=percents(limitcount) if percentamount > 1 then discount=percentamount else discount=percentamount*subtotal end if exit sub end if 'Must be somewhere between low and high for i = 0 to limitcount lowrange=csng(limits(i)) highrange=limits(i+1) If highrange="" then highrange=9999999 end if lowrange=csng(lowrange) highrange=csng(highrange) if subtotal>= lowrange and subtotal < highrange then percentamount=percents(i) if percentamount > 1 then discount=percentamount else discount=percentamount*subtotal end if exit sub end if next end sub %>