Grow your CSS skills. Land your dream job.

Hoping someone can help…

  • # August 19, 2009 at 8:18 pm

    Hi,

    I am trying to make it that a certain bottle of wine has no discount on it regardless of the amount of bottles that are purchased. All others have some kind of discount on the depending on the type of wine.

    I am hoping the following code is all that is needed to make sense.

    Code:
    // priceArr contents = new Array(0=>’displayname’,1=>’variablename’,2=>enabled,3=>retailrate,4=>bottlenum,5=>discount,6=>Was price)
    var priceArr = new Array(

    new Array(’2009 Pinot Gris – Message in a Bottle – All proceeds to World Wildlife Fund’,’2009 Pinot Gris’,1,30.00,1,3,30),
    new Array(’2006 Jackson Barry Pinot Noir’,’2006_Jackson_Barry’,1,28.00,1,0,42),
    new Array(’2007 Jackson Barry Pinot Noir’,’2007_Jackson_Barry’,1,42.00,1,2,42),
    new Array(’2008 Nipple Hill Pinot Noir – 2ND BOTTLING‘,’2008_Nipple_Hill’,1,19.00,1,0,24),
    new Array(’2008 Robert the Bruce’,’2007_Robert_the_Bruce’,1,28.00,1,2,28),
    new Array(’2008 Summer Dreaming Pinot Noir’,’2008_Summer_Dreaming’,1,17.00,1,0,24),
    new Array(’2006 Charcoal Joe Chardonnay’,'Charcoal_Joe_2006′,1,20.00,1,0,24.50),
    new Array(’2007 Bannockburn Club – UNOAKED CHARDONNAY‘,’2007_Bannockburn_Club’,1,18.00,1,0,21),
    new Array(’2007 Riesling’,’2007_Riesling’,1,18.00,1,0,23),
    new Array(’2007 Gewurztraminer’,’2007_Gewurztraminer’,1,18.00,1,0,24),
    new Array(’2008 Gewurztraminer’,’2008_Gewurztraminer’,1,22.00,1,0,24),
    new Array(’2008 Sauvignon Blanc’,’2008_Sauvignon_Blanc’,1,17.50,1,0,22.50),
    new Array(’2003 Autumn Gold – LATE HARVEST CHARDONNAY BUY 1 GET 1 FREE *‘,’2003_Autumn_Gold’,1,28.00,1,0,28),
    new Array(‘Verjuice’,'Verjuice’,1,10.00,1,0,10)

    Each bottle has a ‘discount’ number placed in the array.

    As you can see, the first bottle (Pinot Gris – message in a bottle etc) has a discount number=3 which is what I am trying to target it with for the sepecific discount.

    Below is where the discount is calculated.

    In the second ‘if’ statement I have tried to target the discount=3. I want there to be no discount applied but there is a $100 discount applied if I select over 10 bottles. It is like it is applying the rules of the if statement below the one in question, but I am not sure why. I am not even sure if ‘discount=(0)’ is what i should be using to apply no discount. The other discount rules do work as they are supposed to having tested them.

    Code:
    if(bbclubmember==1 && priceArr[cnt][5]==1)
    {
    discount +=(itemprice * 0.01); // 10 percent discount for club members
    if(itemprice>0)
    {
    UTMI += “UTM:I|” + dateid +”|”+namer+”|”+namer+”|”+namer+”|n”+filler((priceArr[cnt][3] * 0.9),2)+”|”+ numberofitem +”n”;
    }
    }

    if(bbclubmember==1 && priceArr[cnt][5]==3)
    {
    discount =(0); // 0 discount for this discount number
    if(itemprice>0)
    {
    UTMI += “UTM:I|” + dateid +”|”+namer+”|”+namer+”|”+namer+”|n”+filler((priceArr[cnt][3]),2)+”|”+ numberofitem +”n”;
    }
    }

    if(bbclubmember==1 && priceArr[cnt][5]==2 && totalnum >11)
    {
    discount = (100); // 100 bucks discount for club members
    if(itemprice>0)
    {
    UTMI += “UTM:I|” + dateid +”|”+namer+”|”+namer+”|”+namer+”|n”+filler(priceArr[cnt][3],2)+”|”+ numberofitem +”n”;
    }
    }

    else if(bbclubmember!=1 && priceArr[cnt][5]==1)
    {
    if(totalnum >11 && totalnum <24)

    {
    discount +=(itemprice * 0.05);
    if(itemprice>0)
    {
    UTMI += “UTM:I|” + dateid +”|”+namer+”|”+namer+”|”+namer+”|n”+filler(priceArr[cnt][3],2)+”|”+ numberofitem +”n”;
    }
    }
    if(totalnum ==24)

    {
    discount +=(itemprice * 0.07);
    if(itemprice>0)
    {
    UTMI += “UTM:I|” + dateid +”|”+namer+”|”+namer+”|”+namer+”|n”+filler(priceArr[cnt][3],2)+”|”+ numberofitem +”n”;
    }
    }
    if(totalnum >=36)

    {
    discount +=(itemprice * 0.1);
    if(itemprice>0)
    {
    UTMI += “UTM:I|” + dateid +”|”+namer+”|”+namer+”|”+namer+”|n”+filler(priceArr[cnt][3],2)+”|”+ numberofitem +”n”;
    }
    }
    }
    totalprice += itemprice;
    }
    }

    Any help would be great

    Thanks

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".