• Resolved namazee

    (@namazee)


    Based on this form, i would like to get some advice from you,

    If the volumetric weight is higher than the actual weight, i would like to use the volumetric weight for my calculation,

    if the actual weight is higher than the volumetric weight, then i want to use the actual weight for my calculation..

    Is that possible?

    The page I need help with: [log in to see the link]

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

    (@codepeople)

    Hello @namazee,

    You simply should use the “MAX” operation. I’ll try to describe the process with an example, assuming that there are two fields: fieldname1 for volumetric weight and fieldname2 for actual weight, the equation would be:

    
    MAX(fieldname1,fieldname2)
    

    Best regards.

    Thread Starter namazee

    (@namazee)

    i used it but it doesn’t seems to detect the MAX

    (function(){
    MAX(fieldname32,fieldname28);

    if(fieldname32 <= 3) return 51.00;
    if(fieldname32 > 3) return 51.00 +(fieldname32-3) *16;

    })();

    Plugin Author codepeople

    (@codepeople)

    Hello @namazee,

    I’m sorry, but that equation has no sense. You should assign the value returned by the MAX operation to a variable, and then, use this variable in the conditional statements and mathematical operations, as follows:

    
    (function(){
    var m = MAX(fieldname32,fieldname28);
    if(m <= 3) return 51.00;
    return 51.00+(m-3)*16;
    })();
    

    Best regards.

    why this code doesnt function in my calculation ?

    (function(){

    if(fieldname4==1){

    if(fieldname5==”sponge”){

    if(fieldname2>=0.8 || fieldname2<1.1)
    fieldname1=75.00;
    else if(fieldname2>=1.1 || fieldname2<1.5)
    fieldname1=85.00;
    else if(fieldname2>=1.5 || fieldname2<1.8)
    fieldname1=95.00;
    else if(fieldname2>=1.8 || fieldname2<2.2)
    fieldname1=110.00*quantity;
    else if(fieldname2>=2.2 || fieldname2<2.5)
    fieldname1=130.00;
    else if(fieldname2>=2.5 || fieldname2<3.0)
    fieldname1=160.00;
    }

    else
    {
    if(fieldname2>=0.8 || fieldname2<1.1)
    fieldname1=95.00;
    else if(fieldname2>=1.1 || fieldname2<1.5)
    fieldname1=110.00;
    else if(fieldname2>=1.5 || fieldname2<1.8)
    fieldname1=125.00;
    else if(fieldname2>=1.8 || fieldname2<2.2)
    fieldname1=145.00;
    else if(fieldname2>=2.2 || fieldname2<2.5)
    fieldname1=170.00;
    else if(fieldname2>=2.5 || fieldname2<3.0)
    fieldname1=205.00*quantity;
    }
    }

    else if(fieldname4==2)

    if(fieldname5==”sponge”))
    fieldname1=170.00;
    else
    fieldname5=220.00;

    else

    if(fieldname==”sponge”)
    fieldname1=295.00;
    else
    fieldname1=390;

    return fieldname1;

    })();

    Plugin Author codepeople

    (@codepeople)

    Hello @sitisarahothman,

    There are multiple issues in your equation:

    – First in this piece of code the field’s name is wrong: if (fieldname == "sponge") the fields’ names have the structure: fieldname#

    – Second, the plugin replaces all texts with the structure: fieldname# with the corresponding field’s value, so, all pieces of code with the format: fieldname1=#; (like fieldname1 = 75.00; fieldname1 = 85.00; fieldname1 = 95.00; ….) are invalid, because you cannot assign a number to a number.

    – Third, you are using a variable in the equation called: quantity, that is not being defined at least in the equation.

    – Fourth, there are nested condition statements (“if”) that are ambiguos, in this cases you should use the symbols {} to solve the ambiguity and delimit the code that corresponds to each of them.

    Best regards.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘IF Statement’ is closed to new replies.