3 Replies Latest reply on Oct 15, 2009 2:43 PM by kglad

    problem making a mathematical equation

    xranerx

      hi, i got a template that has a built in shopping cart but the shopping cart didnt come with an option to add a shipping price.  So what i want to do is edit the script for the total price to add a shipping price.  the current script looks like this

       


      public function get totalPrice():Number {
        var ruselt:Number = 0;
        var i:Number = _list.length;
        while (i--) {
         var item:ShopingCartItem = _list[i];
         ruselt += Number(item.data.attributes.price) * item.count;
        }
        return ruselt;
      }

       

       

      what id like to do is take that total, and then add a base shipping price of say 9 dollars, and then for every additional item just multiply the total by say 1.1 or so to add a couple dollars per item.  when i put + 9 * 1.1 into the above script, what it seems to do is add 9 for each item in the shopping cart, when i only want it added once for the whole total.  does anyone know how to write it so that it only adds the 9 once total, as opposed to adding it to each item in the cart?  Hopefully this makes sense to someone.  any help is appreciated.

       

      Thanks a lot

       

      Cory