Answered

Booking Form with Calculations

  • 10 March 2022
  • 5 replies
  • 55 views

I am going around in circles trying to create a booking form for a customer of mine. All I want to do is gather the following information from a user and then charge them a fee at the end. There are a few variables, as follows:

 

  1. Date of Arrival
  2. Number of nights stay
  3. Number of Adults at £9 each per night
  4. Number of Children at £7 each per night
  5. Number of Dogs at £2 each per night (maximum of 2 dogs)
  6. Is electric required at £5 per night?
  7. Other basic information such as Name, Address, Email and Telephone.

 

…That’s it.

What I can’t seem to fathom is how to create a calculation which adds up all the relevant quantities and prices and then multiplies the result by the number of nights’ stay.

icon

Best answer by john.desborough 10 March 2022, 22:22

View original

5 replies

Userlevel 7
Badge +6

@thetrew - welcome to the community

let’s assume that you have questions 1-6 already created for the ask for the information. Then you can add the logic rules on question 6 (using the Branching and Calculation) - the following rules are the sort that you need to put in place: 

  • for demo purposes i would create a variable called v_price ( to hold an estimated price before going to a payment question type, v_adults = 9 (default value), v_kids = 7, v_dogs=2, v_electric=5
  • if q3 (# of adults) GT 0 then multiply v_adults by q3
  • if v_adults GT 0 then add v_adults to v_price
  • if q4 (# of kids) GT 0 then multiply v_kids by q4
  • if v_kids GT 0 then add v_kids to v_price
  • if q5 (# of dogs) gt 0 AND q5 LTE 2 then multiply v_dogs by q5
  • if v_dogs is GT 0 then add v_dogs to v_price
  • if q2 is GT 0 then multiply v_price by q2 (the previous rules should have put the ‘cost per night’ for the family into the v_price variable) 

that should do the trick

 

des

Thank you very much, @john.desborough . I really appreciate your time.

I used the v_price variable throughout, as per your example. I can see that the calculations are working, as I have recalled v_price in some text. However, this v_price is not shown in the Credit Card/payment section, only a price of £0.

Should I be using @price instead of v_price in order for the correct payment price?

 

Userlevel 7
Badge +6

@thetrew - you could use price as your variable or simple add another logic rule that says

  • if v_price is greater than 0 add v_price to price 

then you will have the payment amount 

 

i tend to use v_price to be able to show someone an estimated price and then say “are you ok with this price>” as a yes/no question - if yes, do the add from v_ to price.. then go to payment question 

 

 

@john.desborough - That makes sense. I figured that out minutes after sending a reply to you.

 

Whilst I have your attention :wink:  Does it matter what order the logic/calculations flow in, as I realised that I didn’t add any electric price logic into the mix? I was meticulously following your example. Can I simply add the electric calculation to the end of the logic in a similar fashion to your example, followed by the final ‘Always’ + ‘@v_price’ to ‘@price’?

Userlevel 7
Badge +6

@thetrew - shouldn’t be a problem but just check it out a couple of times through.. 

one thing to check, and this may have been fixed a while back, but it used to be that the ‘always’ commands were evaluated first prior any other logic rules.. that may have been fixed but just run a few tests to see.. 

 

cheers

 

des

Reply