Creating the Difference

How to make spaces dropdown required

Posted on: 03-02-2019 Last modified: 03-07-2021
Categories: HTML, JavaScript, PHP, Snippets Tags: ,

What is this post about?

In this post I will explain how you can add make sure that visitors select the correct amount of tickets.

In Event Manager, if you are using the Single Bookings Mode, the selection dropdown for the number of tickets will automatically be set to the first available option.
By default that is 1 ticket, but you can specify more in your event ticket settings.

However… It turns out that some visitors skip over this option and even though they would like to book more than one ticket, they forget to adjust the dropdown accordingly. So then you end up with double bookings, etc.

We can solve that by adding an empty option to the spaces dropdown. We will also set that as default and make sure it is disabled. That way users will get an error when they try to submit the booking without having selected the correct amount of tickets.

Step 1: Add an empty option to the Spaces Select Dropdown:

Add this to your functions.php:Click here to learn how to safely add your code to WordPress.

[php] function stonehenge_em_add_empty_to_spaces() { // Only add the script if this is a single event and has bookings enabled. global $EM_Event; if( is_singular(‘event’) && ‘1’ === $EM_Event->rsvp ) { ?> ⇐ Previous
Next ⇒