How to calculate final price using different and multiple discount categories

Answered

Comments

2 comments

  • Adrien BLAISE

    That may not be the slickest way, but it seems to work:

    var initialPrice = @Price before discount;
    
    var strDiscount = @Discount.join(",").replace("Category 1", 0.8).replace("Category 2", 0.85).replace("Category 3", 0.9).replace("Category 4", 0.98)
    
    var arrDiscount = strDiscount.split(",")
    
    var discount = 1;
    
      for (var i=0; i<arrDiscount.length; i++) {
           discount = discount * arrDiscount[i];
            } 
    
    discount * initialPrice
    
    1
    Comment actions Permalink
  • Cody R. Smith

    Thank you Adrien! It works perfect. JavaScript is amazing in Podio! I am very motivated to learn JS now because there seem to be so many possibilities. Thanks again!

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk