Calculate a Total price, that depends on the sqft variable. Probalby ( <= if then elif )

Comments

4 comments

  • Rainer Grabowski

    Hi Lukas, 

    var sqft = @Sqft;
    var type = @Type of Work.toString();
    var drone = @Drone;
    var tourPrice = sqft > 0 ? ( sqft <= 1500 ? 170  : sqft <= 2000 ? 195 : sqft <= 3000 ? 195  : 245 ) : 0;
    var photoshootPrice = sqft > 0 ? ( sqft <= 1500 ? 89  : sqft <= 3000 ? 119 : sqft <= 5000 ? 149  : 199 ) : 0;
    var dronePrice =  drone ==  "Basic" ? 50 : drone == "Advanced" ? 150 : 0; 
    var totalPrice = tourPrice + photoshootPrice + dronePrice;
    var discountPrice = (tourPrice * .7) + photoshootPrice + dronePrice;
    var finalPrice = type.indexOf("Tour") > -1 &&  + type.indexOf("Photoshoot") > -1  && type.indexOf("Drone") > -1 ?   discountPrice : totalPrice

    Please be aware that with in var tourPrice every lf sqft > 3000 will be counted with 245 and in var photoshootPrice every lf sqft > 5000 with 199. Maybe you need to adjust the sqft spans because in photoshootPrice (in your posting) you've a max of 10000 and in tourPrice 4000 only. I recommend not to have a max value (like in your posting 4000 and 10000) because if the number is greater you won't get a result. 

    Rainer

    1
    Comment actions Permalink
  • Lukas Nach

    Thank you very much Rainer for your time.

    I added these fields to Podio:

    - Sqft ( number )
    - Work ( text )
    - Drone ( category )

    And I added your function to Calculation. It returns "The script returned an undefined result". Could you please help me to solve it, please? I linked all @variables correctly.

    Thank you! Lukas

    0
    Comment actions Permalink
  • Rainer Grabowski

    As last line enter:
    finalPrice

    1
    Comment actions Permalink
  • Lukas Nach

    Ok oh, sure, it works ;) Thank you

    I'd like to have these prices optional. Now it returns the

    dronePrice + PhotoshootPrice + tourPrice no matter if it's selected or not.

    Is there a chance to add a condition, that I can select only one service or two or all three, please?

    Now, when I selected just photos, I am still getting calculated tour with the total. Thank you!

     

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk