• Resolved nasirovemin

    (@nasirovemin)


    Hi,
    i want to calculate rates of yacht rentals. but i cannt.

    Please advise

    I need calculate meter square of yacht (wıdth*lenght) and multiply with days.
    But there is something different.
    There is some states: if meter square of yacht is less than 45 it will be calculate like 45, if meter square of yacht beetween 45 and 56 m/square, if meter square of yacht beetween 56 and 57 m/square and etc. every interval have own coefficient.
    Another state Days: each 31 day have own coefficient. for example from 1 day to 31 day there is meter/square is 2euro. but if there are 360 days it will be 0.6 euro.

    I can send table of all calculated basis.

    Please advise.
    i really appreciate your effort.

    https://wordpress.org/plugins/calculated-fields-form/

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

    (@codepeople)

    Hi,

    Ok, remember you can use conditional statement in the equations:

    So, suppose, your form includes two numeric fields: fieldname1 and fieldname2 for width and length respectively, and two Date fields: fieldname3 and fieldname4, for the start and end dates. Your equation would be similar to:

    (function(){
    var square_meter = fieldname1*fieldname2;
    var period = fieldname4-fieldnam3;
    var result = 0;

    if(square_meter <= 45 ) result = square_meter*coeficient1;
    if(45 < square_meter && square_meter <= 56 ) result = square_meter*coeficient2;
    if(56 < square_meter && square_meter <= 57 ) result = square_meter*coeficient3;
    //… We have a result depending of square meters

    if(period<=31) result=result+square_meter*period*coeficient4;
    //… Set the other intervals

    return result;
    })()

    Note: in the previous equation you should replace the different coeficients by the real value, and complete all conditional statements required by your project.

    Best regards.

    Thread Starter nasirovemin

    (@nasirovemin)

    hi i have 2 dynamic fields.

    fieldname5 is total-meter_square
    fieldname6 is total_days

    i cannt did it.

    please help.

    Plugin Author codepeople

    (@codepeople)

    Hi,

    In the equation I sent you previously you only should replace:

    var square_meter = fieldname1*fieldname2;

    directly by

    var square_meter = fieldname5;

    and

    var period = fieldname4-fieldnam3;

    by

    var period = fieldname6;

    and of course, you should replace the texts: coeficient1, coeficient2,… by the real values, and insert all conditional statements required by your project.

    Best regards.

    Thread Starter nasirovemin

    (@nasirovemin)

    i did it but something wrong i did with all conditions.

    i send you the page

    http://www.kaenem.com/calculated-field/

    admin page:
    http://www.kaenem.com/wp-admin
    username: demo
    password: demo

    please see table with conditions.
    by the way you can see all coeficient for each meter square by days.

    and below calculated fields

    please help

    Plugin Author codepeople

    (@codepeople)

    Hi,

    I’m sorry, but I cannot create all your project. I’ll give you some tips to create your equation, but you should complete all conditional statements.

    In your form the square meter field is the fieldname4, and the number of days is the fieldname5. So, the equation should be:

    (function(){
    if( fieldname4 < 56 )
    {
    if( fieldname5 <= 30 ) return fieldname5*1.84;
    if( fieldname5 <= 60 ) return fieldname5*1.563;
    if( fieldname5 <= 90 ) return fieldname5*1.327;
    if( fieldname5 <= 121 ) return fieldname5*1.305;
    if( fieldname5 <= 151 ) return fieldname5*0.929;
    if( fieldname5 <= 181 ) return fieldname5*0.849;
    // The other days of first row here
    }

    if( fieldname4 < 68 )
    {
    // The conditional statements for the second row
    }

    // Repeat for the other rows in your table of coeficients
    })()

    Best regards.

    Thread Starter nasirovemin

    (@nasirovemin)

    i also didnt want you to finish project but when i paste all code to “set equation” field this didnt work for me.

    i sent the information website. just show me code above. i ll finish all statements.

    Best regards

    Plugin Author codepeople

    (@codepeople)

    Hi,

    The comments in the equation are only for teach you, you should not insert the comments in the equation associated to the field.

    Please, check your form again, I’ve modified the equation in your website.

    Best regards.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘formula needed.please help.’ is closed to new replies.