• Resolved monika999

    (@monika999)


    Hello, amazing plugin. Thanks. I have a problem. I want the booking price to be different after selecting a given day of the week. e.g. Monday – 60 euros Tuesday – 70 euros Wednesday – 50 euros Thursday – 50 euros Friday 60 euros Saturday 40 euros Sunday – 80 euros Please help

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

    (@codepeople)

    Hello @monika999,

    In this case, you must walk the days from checking to checkout and summing the corresponding amounts.

    For example, assuming you have two date fields for the checking and checkout. I’ll call the fieldname1 and fieldname2, and you want to sum their corresponding prices, including the first and last days.

    You can insert a calculate field in the form and enter the equation:

    (function(){
    var prices_list = {
    1:80,
    2:60,
    3:70,
    4:50,
    5:50,
    6:60,
    7:40
    },
    d1 = DATEOBJ(MIN(fieldname1,fieldname2)), 
    d2 = DATEOBJ(MAX(fieldname1,fieldname2)), 
    result = 0;
    
    while(d1<=d2){
    result += prices_list(WEEKDAY(d1));
    d1.setDate(d1.getDate()+1);
    }
    
    return PREC(result,2);
    })()

    And that’s all.

    Best regards.

    Thread Starter monika999

    (@monika999)

    Hi. Thanks for the quick reply. That’s not exactly what I had in mind. The idea is that after selecting a given day from the calendar (su, Mo..), the final result will display the number (price) assigned to it.

    Plugin Author codepeople

    (@codepeople)

    Hello @@monika999

    In this case, the process is simpler. Assuming the date field is the fieldname1, the equation in the calculated field would be:

    
    ({1:80,2:60,3:70,4:50,5:50,6:60,7:40})[WEEKDAY(fieldname1)]

    Best regards.

    Thread Starter monika999

    (@monika999)

    You are amazing. Thanks. What if we took into account that until 4 p.m. the price = 60, and after 4 p.m. the price = 80 every day??? Thank you for your help:)

    Plugin Author codepeople

    (@codepeople)

    Hello @monika999

    In that case, you must use operations like HOURS and include conditional statements as part of the equation. Learn more about the Date/Time operations module by reading the following section in the plugin documentation:

    https://cff.dwbooster.com/documentation#datetime-module

    If you require assistance implementing your equations, please contact us through the plugin website.

    Best regards.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘problem with setting dates’ is closed to new replies.