Appointment Hour Booking Blog

The easy way to create powerful booking forms for WordPress websites.

Blog / Adding quantity dependent fields

Adding quantity dependent fields

The conditional logic or dependent fields feature allows to show or hide fields depending on a user's selection. This article is a work around to extend that functionality to the calendar "Quantity" drop-down field.

As mentioned,the conditional logic can be used for example,to make a single field appear when the user selects a specific option from a drop-down field. Please read first the info about Using the conditional logic / dependent fields.

If you are already familiar with Using the conditional logic / dependent fields then the steps explained below are a workaround to set conditional rules (dependent fields) for the quantities allowed in the calendar.

#1- The first step is to add an additional drop-down with the same number of options than the max quantity in the calendar (each position number in the dropdown will be linked to the related quantity number).

#2- The dependent fields will be defined for this new drop-down added. See the following screenshot:

adding quantity dropdown

#3- Important: Add the styles "linkto_quantity" and "hide" to link the drop-down field to the calendar quantity and to hide the dropdown field (no need to make it visible).

The additional drop-down will appear only in the administration area, it will be hidden form the public website.

#4- When done the three steps above, paste the following script (can be copied below in this page) in the "General Settings >> Edit Scripts" area as displayed in the following image:

adding custom script

The following is the custom script you have to copy and paste into the "Edit Scripts" area:

Finally check the result in the public booking form, after selecting a quantity in the calendar the related number of fields will be displayed in the form:

adding custom script

Feedback about these features will be welcome, feel free to open a support ticket for any question.