• Resolved cath_allen14

    (@cath_allen14)


    Hi,

    I have a form that calculates a price based on the material selected and the length and depth of the material required.

    I would like to apply a discount of 15% if the overall total is equal to or greater than £600.

    Is this possible? I can’t seem to figure it out.

    Thanks in advance.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @cath_allen14

    Yes of course. I’ll try to describe the process with a hypothetical example.

    Assuming the current equation is: fieldname1+fieldname2

    You simply should edit it as follows:

    
    (function(){
       var result = fieldname1+fieldname2;
       if(600 <= result) result *= 0.85;
       return PREC(result, 2); 
    })()
    

    and that’s all.
    Best regards.

    Thread Starter cath_allen14

    (@cath_allen14)

    Perfect – that works!

    Thanks so much.

    What if I wanted the discount to be a £ value rather tahn a %. e.g. apply a discount of £50 if the overall total is equal to or greater than £600.

    Thanks in advance!

    Plugin Author codepeople

    (@codepeople)

    Hello @cath_allen14

    The solution would be exactly the same:

    
    (function(){
       var result = fieldname1+fieldname2;
       if(600 <= result) result -= 50;
       return PREC(result, 2); 
    })()
    

    Best regards.

    Thread Starter cath_allen14

    (@cath_allen14)

    Great – thanks for your help ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Apply discount if value is greater than’ is closed to new replies.