"Undefined" error when booking an appointment

Support forumCategory: Bugs"Undefined" error when booking an appointment
Baboe asked 10 months ago
Just like Marvin, https://easy-appointments.net/support/undefined-error-when-booking-an-appointment/   I experience the exact same problem. 1 out of 10  times it randomly works, but in all other cases it gives the undefined popup. ( website says: undefined )   It does block the time slot, but no data gets registered, and you won`t get Detoured to the thank-you page. which you normally would.
2 Answers
Nikola Loncar Staff answered 10 months ago
Hi, can you please share the link to that page with EA form? Best regards, Nikola
twanny replied 4 months ago

Hi Nikola,

I am having the same issue with the ‘undefined’ error when trying to book an appointment. Same result like Baboe has described. Can you help please?


twanny replied 4 months ago

@Nikola Lonecar, here is the link to the page with the EA form – https://ponyroadautospecialists.com/contact-us/booking/

twanny replied 1 week ago

I am still waiting for an answer on this issue. After countless emails and comments on multiple forum, still no answer. Let me know if you require moreinformation please.


blurby_kft replied 6 days ago

Hi Nikola,
We have exactly the same issue with the undefined error.
Here are the booking forms:

blurby_kft replied 6 days ago

Let me know if you need anything from our backend or Cpanel to get it fixed.

Nikola Loncar Staff answered 6 days ago
@twanny it is requesting password to access that page? Best regards, Nikola
twanny replied 5 days ago

9876 to access the booking

blurby_kft replied 5 days ago

Hi @Nikola,
I think our hosting provider found what is the issue. Can you please check if it is correct and if yes then make a bug fix accordingly? Here is the email from our hosting provider:

We have found the exact problem.

The issue is inside the method ajax_final_appointment inside the plugin file src/ajax.php.

This function/method is called upon form submission. During form creation, this plugin creates a database record with the IP address of the user filling out the form. While finalizing the form, it verifies if the IP address is the same, using the $_SERVER["REMOTE_ADDR"] PHP super global variable.

However, this variable does not work with Cloudflare as Cloudflare uses a reverse proxy type system, and this variable would basically receive an IP different to the user's real IP.

Simply disabling this check in the code makes the appointments go through.

Appointments should now work on blurbybike.com.

This fix is slightly ugly, as it is a direct edit inside a plugin file, and updating the plugin in the future would override this edit.

I would recommend, if you go with this fix, to let the plugin developer know of this bug (they should either handle cloudflare kind of a situation in the code or skip this step). Until the plugin developer updates a fix, and you want to go ahead with this fix, you will either (i) not want to update the plugin OR (ii) Add this modification to the code everytime you update the plugin.

Let me know if you are okay with this fix, and I can apply this to the rest of your websites.


Attached code & comments:

We just commented out the lines inside the file /wp-content/plugins/easy-appointments/src/ajax.php , in the method ajax_final_appointment
These lines enforce an IP check – that the user starting and finishing the form, originates from the same IP address. But $_SERVER["REMOTE_ADDR"] will not serve the correct IP address if website is behind Cloudflare proxy.

//Hustly disabled these lines as $_SERVER['REMOTE_ADDR']) does not work with Cloudflare.
//error_log('Debugging: IP Address Check – $appointment["ip"]: ' . $appointment['ip']);
//error_log('Debugging: IP Address Check – $_SERVER["REMOTE_ADDR"]: ' . $_SERVER['REMOTE_ADDR']);

// check IP
//if ($appointment['ip'] != $_SERVER['REMOTE_ADDR']) {
// $this->send_err_json_result('{"err":true}');

twanny replied 4 days ago

Thanks Andrew. This seems like it is working for me too now. Many thanks for a very good and positive contribution.