• Resolved lfedele

    (@lfedele)


    Dear support,
    what if the stay period for a booking form is among two different prices periods? In other words when it begins in a price date range and it ends in another one. Let’s say the room price is 100 € per night in March and 120 e per night in April, if I want to reserve a room from March 29th (check-in) to April 2nd (check-out) the price will have to be 420 €, not 400 €.

    Is there a way to manage this?

    Thanks in advance.

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

    (@codepeople)

    Hello @lfedele

    Yes, of course. That’s possible. But, you must sum the price per day. For example, assuming the from and to dates fields are the fieldname1 and fieldname2, respectively, you can implement the equation as follows:

    (function(){
    var _from = MIN(fieldname1, fieldname2),
    _to = MAX(fieldname1, fieldname2);
    _price = 0;
    
    while(_from < _to){
    if(MONTH(_from) < 4 ) _price += 100;
    else _price += 120;
    
    _from++;
    }
    return _price;
    })()

    Best regards.

    Thread Starter lfedele

    (@lfedele)

    Hello @codepeople,
    thanks for your quick reply. What if I have to set a different rate for each month?

    Moreover how can I set a minimum stay? So that the user can’t select a check-out day earlier than 3 days after the check-in?

    Plugin Author codepeople

    (@codepeople)

    Hello @lfedele

    Assuming the price for January is 100 per day, February 105 per day, March 110 per day, April 130 per day, May 90 per day, June 98 per day, July 200 per day, August 180 per day, September 84 per day, October 210 per day, November 99 per day, and December 220 per day. Also, if the user selects less than three days, you want to display the message “Selects at least three days”.

    The equation could be:

    (function(){
    var _price_per_month = {
    1:100, 
    2:105, 
    3:110,
    4:130,
    5:90,
    6:98,
    7:200, 
    8:180, 
    9:84, 
    10:210, 
    11:99,
    12:220},
    _from = MIN(fieldname1, fieldname2),
    _to = MAX(fieldname1, fieldname2);
    _price = 0;
    
    if(ABS(_to - _from)<3) return 'Selects at least three days';
    
    while(_from < _to){
    
    _price += _price_per_month[MONTH(_from)];
    _from++;
    }
    return _price;
    })()

    Best regards.

    Thread Starter lfedele

    (@lfedele)

    Hello @codepeople,
    it seems to work quite properly, it just counts one day less when calculating the price.

    About the minimum stay, what if I wanted to set it in the “Minuto date” field of the check-out date? I tried to add “fieldname7+3d”, but it did not work.

    Thank you so much!

    Plugin Author codepeople

    (@codepeople)

    Hello @lfedele

    You cannot evaluate mathematical operations in different fields from calculated fields. You cannot enter fieldname7+3d in the date field settings. So, you can insert an additional calculated field in the form to use as an auxiliary.

    Assuming the date fields are the fieldname1 and fieldname2 and have the format mm/dd/yyyy:

    Insert the new calculated field (I will assume it is the fieldname4). This field can be excluded from submission and hidden by ticking two checkboxes in its settings. And enter the equation:

    CDATE(fieldname1+3, 'mm/dd/yyyy')

    Finally, enter the name of the calculated field fieldname4 in the “Min date” attribute of the fieldname2 date field.

    Best regards.

    Thread Starter lfedele

    (@lfedele)

    Hello @codepeople,
    it perfectly worked, thank you.

    What about the code you previously provided? As mentioned it currently counts one day less when calculating the price.

    How can I manage this?

    Plugin Author codepeople

    (@codepeople)

    Hello @lfedele

    You would have two calculated fields. The first one calculates the price as I described in previous entries. And the second one is used as an auxiliary only to vary the “Min date” attribute in the second calculated field.

    Best regards.

    Thread Starter lfedele

    (@lfedele)

    Hello @codepeople,

    sorry for the misunderstanding, I meant the equation.

    Plugin Author codepeople

    (@codepeople)

    Hello @lfedele

    In this case, instead of using while(_from < _to){ you should use while(_from <= _to){

    Best regards.

    Hello, support, Assume fieldname1 is the currency field and fieldmame2 is the drawdown field and the fieldname3 is calculated total fees,fieldname4 calculated fieldname1-fieldname3(currency-total fees)& fieldname5 is calculated Fieldname1+fieldname(currency-total fees).

    Drowdownfield is(In fielname2)

    Domestic
    3.49%+$.49(Invoicing,PayPal Checkout,Venmo)
    2.99%+$.49(Credit and Debit Cards)
    2.89%+$.49(Goods adn Services,Donations)
    1.99%+$.49(Charity)
    4.99%+$.09(Micropayments)
    3.5%(PayPal Guest Checkout-American Express Payments)
    1.9%+$.10(QR Code-$10.01 and above)
    2.4%+$.05(QR Code-$10 and below)

    International
    4.99%+$49(Invoicing,PayPal Checkout,Venmo)
    4.49%+$.49(Credit and Debit Cards)
    4.39%+$.49(Goods and Services,Donations
    3.49%+$.49(Charity)
    6.49%+$.09(Micropayment)

    How show the result in the calculated field as user choose the option

    Plugin Author codepeople

    (@codepeople)

    Hello @ajaysingh121 ,

    A better alternative would be to assign identifiers to the dropdown choices and include a plain object in the equation with the values to use in the calculations. For example, assuming the dropdown field fieldname1 has three choices with values 1, 2, and 3, respectively, and fieldname2 is a number, currency field, calculated field, or any other field I will use in the equation. A hypothetical equation would be:

    (function(){
    var obj = {
    1:{'percent':0.0349, 'base':0.49},
    2:{'percent':0.0499, 'base':0.49},
    3:{'percent':0.0649, 'base':0.09}
    };
    
    return fieldname2*obj[fieldname1]['percent']+ obj[fieldname1]['base'];
    })()

    Best regards.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Date based price’ is closed to new replies.