Appointments create/edit from wp-admin error

When I am trying to create/edit appointments in the admin screens, the plugin shows me a Javascript message "Unexpected error". How can I solve this?

  • Kasia Swiderska
    • Support nomad

    Hello David,

    I'm sorry to hear about this issue with our plugin.

    I have performed a plugin conflict test on your site and checked all the add-ons in Appointments+ (I have performed a backup before doing any changes) and there was still no change.
    I was able to save appointment but changing provider showed error and the time select was not available.
    I will need to escalate this to our Second Line Support Developers for further checking and providing a fix for this issue.
    We will keep you posted about our findings.

    kind regards,
    Kasia

  • Panos
    • SLS

    Hi David @ BBS !

    What I see is that in your providers' Working Hours, most of them have the Work to No. For those plugin can't find any available hours but the error message is confusing. We'll fix that message in future update.

    Could you set those options to Yes for those Providers working? I would do it my self, but I don't know which days to set. Please let us know if you still have this issue after updating those working hours.

    Kind regards!

  • David @ BBS
    • Site Builder, Child of Zeus

    Still an unresolved issue. The providers I tested this for have their work days set to yes and hours set to 12am-12am, so all day availability. Yet still getting same error. Try creating an appointment with our provider (Babysitters) Barbra Streisand (test provider). You'll be able to recreate the error.

  • David @ BBS
    • Site Builder, Child of Zeus

    Hi Patrick,

    Thanks for the quick reply. Unfortunately your explanation seems to directly contradict the way the plugin normally handles those hours. In fact, the FAQ specifically says that for cases where the working hours include or are past midnight, you should:
    "Set your working hours as 24am to 24am (00:00 to 00:00)"
    Which is what we're doing. Specifically because our appointments can be booked 24/7.

    What I've noticed is that if I set the working hours for just one day (any day) to 12am–11:45pm (or any other end time) the Javascript "Unexpected Error" message disappears. However, if I have all the hours set as 12am–12am the errors are constant.

    Please provide a work-around for this.
    Thanks!

  • Panos
    • SLS

    Hi David @ BBS !

    So sorry for such a delay. From what I see this is not allowed in code. And if this is changed it times-out and the site becomes unresponsive (at least my test sites). By setting the end time though to 23:45 in code it seems to load times fine without affecting the front end available time slots. If you are interested to try it out, you can replace file:
    wp-content/plugins/appointments/includes/helpers.php
    with the one attached here. I would strongly recommend to first try it out on a test site.

    Kind regards!

  • David @ BBS
    • Site Builder, Child of Zeus

    Hi Panos,

    Thanks for sending this along. This solves some issues, but poses other problems:

    1. It got rid of the error messages, so that's nice. Thanks!
    2. Unfortunately, it is still throwing notices for some providers. Check provider Sarah Tr[****]r (removed details for privacy). The notice is as follows:

    file: "wp-content/plugins/appointments/includes/helpers.php"
    line: 298
    message: "Undefined index: active"
    stack: Array(3) [ "appointments_get_worker_weekly_start_hours()", "Appointments_AJAX->inline_fetch_worker_slots()", "do_action('wp_ajax_inline_fetch_worker_slots')" ]
    type: "notice"

    3. It also seems to grab only working hours for today. Changing the day doesn't update the available hours. Which means that the back-end admin system gives us no way of knowing if a provider is in fact available to work during those hours or even working that day. Please help.

    I have enabled Support Access. Will email you login and FTP credentials for this secondary staging site now.

    Thanks!

  • Panos
    • SLS

    Hi David @ BBS !

    Good to know those errors are gone. In regards to the notice it's nothing that would affect functionality however I have applied some changes that should remove those notices too.

    As for checking availability in admin this is not available by default. What it currently does is list all working hours from all working days. The feature you suggest requires a lot of changes to accomplish and we're not really adding any new features to Appointments plugin currently. The availability check is done only in front end which you can use as an alternative.

    The file I have replaced on your staging site is the same one:
    wp-content/plugins/appointments/includes/helpers.php
    and I am attaching here so you can move to your live site after testing it :slight_smile:

    Kind regards!

  • David @ BBS
    • Site Builder, Child of Zeus

    Hi Panos!

    Thanks for the update. Can you explain what you mean by

    What it currently does is list all working hours from all working days.
    ? How can I view the working hours from all working days while creating an appointment from the backend? It seems that it's only grabbing the working hours for today so that seems to be the only thing I'm seeing. What am I missing?

    Thanks!
    David

    David

  • Kasia Swiderska
    • Support nomad

    Hello David @ BBS ,

    How can I view the working hours from all working days while creating an appointment from the backend? It seems that it's only grabbing the working hours for today so that seems to be the only thing I'm seeing. What am I missing?

    I'm sorry for the confusion - what Panos meant it will show working hours for the day, but show no matter if they are busy or free. So all working hours for that day, that are set up in the Working hours' tab.

    kind regards,
    Kasia

  • David @ BBS
    • Site Builder, Child of Zeus

    Hi Kasia,

    I have tested and tested and can't replicate your supposed behavior. It looks like instead, what the plugin is doing is grabbing the earliest start time for any of the work days from the week and the latest end time for the week. Changing days in the calendar doesn't actually update the dropdown. See my screen recording for the replication.
    https://www.dropbox.com/s/43e94e6zuv4fr6b/Appointments%20Working%20Hours.mov?dl=0

    Thanks,
    David

  • David @ BBS
    • Site Builder, Child of Zeus

    Kasia Swiderska & Panos,

    Having played with the updated script all evening long, additional problems have surfaced. All of these bugs seem to be related to attempts to get the weekday_number as well as the price for the service, both of which seem to generate warnings.
    Here's another screen recording showing you these particular problems.
    https://www.dropbox.com/s/nssoacl6d02ty0w/Appointments%20More%20Php%20Warnings.mov?dl=0

    I also found that (if I'm not mistaken) there's a typo in the class-app-ajax.php script. Line 332 which says wp_send_json( $worker_slots ); should be replaced with wp_send_json( $result ); which will finally successfully generate the red ajax error messages you see in my screen recording.

    Please let me know what you find on all of the above.

    Thanks!
    David

  • Rupok
    • Support Ninja

    Hi David,

    I'm so sorry for the delay in response and I do apologize for it. I've already pinged Panos to have a look at the file you mentioned. He will come up with his valuable feedback on this very soon. I'll request you to give us a little more time until he replies here.

    I really appreciate your patience.

    Regards,
    Rupok

  • Panos
    • SLS

    Hi David @ BBS !

    Apologies again, I missed replying here and just realized after doing some housecleaning.

    It looks like instead, what the plugin is doing is grabbing the earliest start time for any of the work days from the week and the latest end time for the week. Changing days in the calendar doesn't actually update the dropdown.

    This is correct, that is the list which contains all available slots and it spans over all week's open hours. The initial intention of this feature was a list of timeslots not that strict as in front end that would allow double bookings and use slots on non working hours. Adding new features here is out of scope I'm afraid.

    In regards to the error in the screencast (thanks for that btw!), I don't see that in your test2 site. It seems that it is related to the math operation to add 2 numbers, one of which is not a number. Haven't met this issue but we could force them to number formats if you still get this error.

    About the error message you mention for line:
    wp_send_json( $worker_slots );
    you are correct it should be :
    wp_send_json( $result );

    Thanks for spotting this. That will be pushed to the github repo shortly unless you would like to do it :slight_smile:

    Kind regards!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.