• Resolved nathalizator

    (@nathalizator)


    Hello again !
    As you might know, i’m using the calculated field as calculator for car rental.
    Most of the feature fit my needs but i was wondering something.

    My client want to include a discount price when more that 3 days are selected.

    Just to remember, my calculator is made of a date picker + dropdown element.
    Total is :
    abs(fieldname2-fieldname1+1) * (fieldname6)

    Fieldname1 Is Check in Date and Fieldname2 is Check out date Fieldname 6 is a dropdown menu with the car ( Choice = Mercedes , Value = 2000 )

    QUESTION : Is it possible to decrease the value ( for example ) if the client select more that 3 days ?

    For example :

    if the client select from 1 to 3 day value is normal : 2000 * nb of days selected
    If the client select from 3 to 7 days : 2000-20% = 1600 * nb of days selected
    If the client select more that 8 days : 2000-40% = 1200 * nb of days selected

    • This topic was modified 9 years, 1 month ago by nathalizator.
    • This topic was modified 9 years, 1 month ago by nathalizator.
    • This topic was modified 9 years, 1 month ago by nathalizator.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello,

    Yes of course, and the process is very simple:

    The equation would be:

    (function(){
    var days = abs(fieldname2-fieldname1+1), discount = 1;
    if(3<days) discount = 0.8;
    if(7<days) discount = 0.6;
    return days*fieldname6*discount;
    })()

    Best regards.

    Thread Starter nathalizator

    (@nathalizator)

    Thats work wonderfully good ! You definitly made the most flexible calculated field plug-in on wordpress !
    I will need one last thing with this , is this possible to round to the hundredth ? If i have a result like 2370, i would rather have it like 2400 ?

    Thanks a lot again…

    • This reply was modified 9 years, 1 month ago by nathalizator.
    Plugin Author codepeople

    (@codepeople)

    Hello,

    Yes, of course, you simply should apply the operation: CEIL(Number/100)*100

    For example:

    CEIL(2370/100)*100 = CEIL(23.7)*100 = 24*100 = 2400

    Best regards.

    Thread Starter nathalizator

    (@nathalizator)

    Perfect ! Thanks

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘DatePicker Discount ?’ is closed to new replies.