by mjbrunelle » Thu Nov 12, 2009 7:42 pm
I pull the discount for pricing from the Coupon name that ShopSite stores in the customer cookie. Then calculate the discounted price for display.
ie: "|DIS30Toyota Corporation"
function disPrice(listPrice)
{
var cookie = document.cookie;
var discount = cookie.indexOf("|DIS");
var signedIn = cookie.indexOf("|yes");
var Price = listPrice;
if ((discount != 0) && (signedIn != -1))
{
var disPercentage = cookie.substring(discount + 4,discount + 6);
var workPrice = listPrice.substring( 1, listPrice.length);
var locComa = workPrice.indexOf(",",0);
if (locComa)
{
workPrice = workPrice.substring(0,locComa) + workPrice.substring(locComa+1,workPrice.length);
}
var Price = (workPrice * ((100 - disPercentage)/100)).toFixed(2);
if (Price.length>6)
{
Price = Price.substring(0,1) + "," + Price.substring(1,Price.length);
}
Price = "$" + Price;
}
document.write(Price);
}