PBBooking Always Displays “There is a problem with the booking. Maybe the time has already been booked or you specified an invalid email address.” Error

If you constantly receive this error message there are usually five possible causes.

  1. The email address is not valid, or no email address has been specified in the custom fields. Ensure an email address is listed in the custom fields.
  2. Another user has since booked the available time or the calendaring hours have changed and the appointment is now busy.
  3. You are using PBBooking <= 2.4.5.11 and there is a conflict between Mootools and jQuery
  4. You are using PBBooking >= 3.0.0 and jQuery is being loaded multiple times on the page
  5. You are using PBBooking >= 3.0.0 and your host has mod_security installed and is blocking needed files.

I will step through the final three in more detail.

PBBooking <= 2.4.5.11 and Mootools / jQuery Conflicts

PBbooking versions <= 2.4.5.11 uses both the MooTools and jQuery frameworks. MooTools was the default Javascript framework used in Joomla 2.5 and jQuery was officially added to the Joomla project with the release of Joomla 3.

When using both MooTools and jQuery on the same page jQuery needs to be running in noConflict mode() to avoid overwriting the MooTools $ selector. You can find out more about jQuery’s noConflict() mode in the jQuery docs here: http://api.jquery.com/jquery.noconflict/

To ensure jQuery is running in noConflict() mode find where jQuery is being loaded and ensure that the line:

jQuery.noConflict();

appears immediately after.

NB: It is is important that the call to jQuery.noConflict() occurs, immediately after loading jQuery.

You can test whether jQuery is correctly running in noConflict() mode by using something like Chrome Developer Tools. Open Chrome Developer Tools and go to Console and just type: $

If jQuery and MooTools are both working correctly then the output should be:

You can see from this image that the $ selector is linked to the MooTools javascript library.

If jQuery and MooTools are not working correctly together then the output will return the below.

In this second example you can see that the $ selector is linked to the jQuery javascript library.

To correct this you need to identify which extension or template is loading jQuery without including noConflict() mode and correct accordingly. This may require either trial and error, or the extension may be identified in the URL used to load the jQuery library.

PBBooking >= 3.0.0 and jQuery Is Being Loaded Multiple Times on the Page

Joomla 3.3 has made a lot of things easier, most notably is that jQuery is now a standard part of the CMS.

In Joomla 3.3 the syntax to load the jQuery framework is Jhtml::_('jquery.framework');. The advantage with loading jQuery using the CMS provided helper is that loads only one instance of jQuery regardless of how many times the helper is called.

Unfortunately there are still situations where jQuery is loaded multiple times on the page. This will increase page load times and also cause problems where a developer has previously loaded jQuery based plugins.

PBBooking uses two jQuery plugins:

  • jquery-dateFormat – used for formatting of dates and tracking the start and end date of bookings
  • jquery-cookie – used to store user information to a cookie that can reload information between page refreshes when changing dates in single page checkout.

If second copy of jQuery is loaded the existing jQuery namespace is overwritten and these plugins are no longer available. This causes Javascript errors and prevents the scripts from running and keeping the dates updated.

You can tell if this is a problem by viewing the source of your document and checking for the following:

To correct this you need to identify which extension or template is loading jQuery without using the Jhtml::_('jquery.framework') command. This may require either trial and error, or the extension may be identified in the URL used to load the jQuery library.

PBBooking >= 3.0.0 and Your Host Has Mod_Security Installed

mod_security is a popular Apache extension used by many hosts to help reduce security problems. The jquery.cookie.js javascript used by PBBooking can sometimes be blocked by mod_security because of the word cookie in the file name.

This means that when PBBooking tries to use the jquery.cookie() function to reload user data the function is not there and throws an undefined function error and preventing the rest of the script from running on that page.

You can check if this is a problem by using something like Chrome Developer Tools. If mod_security is blocking this file you will see something like the below:

To correct this just get your host to add an exception to your hosting account for the specific mod_sec rule. They will know how to do this, it’s quite an easy process and usually takes less than 5 minutes to find the rule and whitelist. On my host with the current version of mod_sec the rule that was causing the problem was rule ID 1234123404. But they can double check the rule ID in the error_logs.

If they can’t or won’t do this for you raise a support ticket and I will be able to give you a change to remove the need for it. The problem is that it will mean the user will need to re-enter their information on every page refresh. For example if they select one date, enter all their data but then can’t find a timeslot and go to another day they will have to enter their data all over again.