Customize the dynamic booking price calculation

Hi Team,

So I am working on a custom feature for our website and I have added a new field in the form booking_make as shown below.

It seems there is a onblur event when we introduce “horas por dia” (we translated it, but it should be number of guests) and it update the price of the booking automatically. I have been checking where is the code/logic to calculate this price without success.

I have been checking in the booking controller in the hivepress-booking plugin.
Does anyone know where is that code located?

What I need basically is add a extra value based on the new field that I created (“Numero horas”).

Many thanks in advance!

Hi,

We recommend using existing available features that you can customize without using code. Please check these docs: How to add guests to bookings - HivePress Help Center or How to enable price extras - HivePress Help Center

P.S. If you purchased a theme or extension, please enter the license key in the forum profile settings, this will enable the Premium Support badge and ensure a 24-hour turnaround time.

Hi Andrii,

Thanks for your replay. I just put the license key in my profile.

So, yeah I am already using the feature of ‘guests’, I renamed it to ‘horas por dia’ if you check in the image above, however, I need another attribute like that (guests), but I am calling it ‘numero horas’ for a different thing. The extra price feature does not provide an input to the user like the ‘guests’ where the user can introduce a number. seems like extra prices are only checkboxes.

I am not using the hivepress framework for a ‘booking’ application.

Let me provide context, I am using the guests feature for something like ‘cups of coffee per day’(let’s say this is X) and the other field that I am trying to implement is ‘cups of extra coffee per booking’ (lets say this is Y), so the user usually will drink X cups of coffee per day, but he can drink extra coffees during the whole booking, that is when Y comes in. e.g the user selects X=2 and Y=2 and the booking has a duration of 3 days, it means that the client will drink 2 coffee per day but he has 2 extra coffees during the service, so He can drink 1 more on the first day, and the other in the 2/3 or even consume the other 2 extra coffees in 1 day. I hope that is clear enough.

In regards to, modify the code, yeah I am just trying to understand the flow and implement a code snippet or something to add the logic to calculate the total properly with the new field ‘numero horas’.

Many thanks in advance

Hi,

Thanks for the details, but you need a custom implementation here. You can add a new field using the hivepress/v1/forms/listing_buy hook and then catch the value in hivepress/v1/models/listing/cart and change the price there depending on what you specified in the field.

I believe this will be useful to you.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.