• Resolved ViktorWoWReklambyra

    (@viktorwowreklambyra)


    Hello! Love the plugin. I’m trying to make a bulk discount calculator so that i can show customers excactly how much they’re saving and what the total is depending on how many items they’re adding.

    Example:
    Item costs 14,50 EUR. If a customer add between 5-9qty it should show the total value with a 1% discount, as well as how much they’re saving. Next step is 10-14 which equals 5% discount, and then 15-20 should show with a 8% discount.

    The calculations are not the problem, the problem i’m having is showing and hiding the correct calculated price depending on what quantity range they’re in.

    I have tried working with dependencies like this: 5<=value && value<9 show 1% discounted price output field and this works well when i’m only using one interval, but as soon as I add another quantity range:”10<=value && value<14″ it either shows both discount fields or messes up the calculations.

    Any tips on how to approach this issue?

    Any support with this would be greatly appreciated!

Viewing 1 replies (of 1 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @viktorwowreklambyra,

    I’ll try to describe the process with an example. Assuming your form includes two fields. for the price and quantity: fieldname1 and fieldname2 respectively, and you current equation is: fieldname1*fieldname2

    In this case the equation would be as simple as:

    
    (function(){
    var result = fieldname1*fieldname2, discount = 1;
    
    if(5<=fieldname2 && fieldname2<=9) discount = 0.99;
    if(10<=fieldname2 && fieldname2<=14) discount = 0.95;
    if(15<=fieldname2 && fieldname2<=20) discount = 0.92;
    
    return result*discount;
    })()
    

    and that’s all.
    Best regards.

Viewing 1 replies (of 1 total)
  • The topic ‘Multiple dependencies in number range’ is closed to new replies.