"Undefined" error when booking an appointment

Support"Undefined" error when booking an appointment
Baboe asked 2 years ago
Just like Marvin, https://easy-appointments.com/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.
3 Answers
Nikola Loncar Staff answered 2 years ago
Hi, can you please share the link to that page with EA form? Best regards, Nikola
twanny Staff replied 2 years 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?

Regards

twanny Staff replied 2 years ago

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

twanny Staff replied 1 year 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.

Regards

blurby_kft Staff replied 1 year ago

Hi Nikola,
We have exactly the same issue with the undefined error.
Here are the booking forms:
https://blurbybike.com/testride/
https://blurbybike.hu/tesztkor/

blurby_kft Staff replied 1 year ago

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

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

9876 to access the booking

blurby_kft Staff replied 1 year 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.

Regards,
Andrew

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 Staff replied 1 year ago

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

Regards

Twanny

Nikola Loncar Staff replied 1 year ago

Maybe the best way to handle that is to make an exception for that page to not be cached via Cloudflare.

Best regards,
Nikola

chrslcy Staff answered 1 year ago
For anyone having this issue, the only way I manged to resolve this problem is to use the 'Freesoul Deactivate Plugins' plugin on the WordPress repository to deactivate all unessential plugins on the appointment booking page.