A+ needs a fourth color with durations Add-on

Ok, so this is the deal we use 15min time base as we have multiple different services to select, like massage lengths :slight_smile: and we want to allow people to select visiting times to arrive as much as possible, therefore the 15min time base and "Minimum time based appointment duration calculus (legacy)" used.

Everything works nicely except one thing. See this screenshot of calendar. In one day we have existing appointment for 60min service starting at 16:00 (which is correctly marked with orange), however when the next person is selecting where he can create an appointment, the system marks the three starting times to close to the next appointments (15:15, 15:30, 15:45) as "Not Possible" color coding.

I understand the logic why, however many customers are simply confused because the "Not Possible" color code in A+ is also used for out of office hours, breaks and other periods of closure times. What is then worse as people try to be smart and select only times like 14:15 manually to avoid this grey area and this creates an empty window in our business and waste of time.

Would it be possible to get a 4th color coding here ? Something to extend the simple "free, busy, not possible" with a 4th color "part of previous timeslot".

If this is not officially supported, can a dev point me to the php code that is marking these small fields with "not possible" so that I can manually mark them with additional color?

PS: Alternative approach here would be to change the "on-hover" color changing when people are looking for appointment slots to indicate with color change not only one slot, but to have the "on-hover" function change color on multiple slots that are part of the same service (ergo with 15min base and 60min service, the on-hover would light-up 4 slots to indicate how long the service would take from the calendar).

  • Ivan

    Hey there Peter,

    Hope you are having great week so far!

    I understand you completely, but even if you do change the color for this slots, the user might be still selecting the 14:15 slot - just to be sure.

    I think a better solution will be some explanation on the appointments page for the users how the system works, because they will keep booking the same way even with different color.

    Still if you want you can submit feature request for this, or I can call help from our SLS(second level support) to point you to the code in A+ you could change to achieve this, as this is above my knowledge of A+ code.


  • Peter

    Hello Ivan,

    Ok, I might go with the feature request later. But for my immediate needs, I would like you to escalate this to second level support as I at least want a developer here pinpointing to me the last "IF" php statement in the code that is giving these fields their "not possible" status right now (I am not enjoying doing reverse-engineering of whole A+ code to find this).

    With that information I will be able to
    A) either change the code to a different "4th" color manually in the php code, or
    B) (alternative my management wants) disable this blocking and make these "not possible" boxes available again for booking without restrictions (we still believe our customers are intelligent enough to not order 60min massage 15 min before the next customer, and if yes then we do not confirm appointment and call them back to reschedule by traditional means).

  • Jude

    Hi Peter,

    Adding a fourth color to the admin side can be done by adding a key value pair to the array returned by app_box_class_names. For details look at function get_classes() on line 1206 in appointments.php

    Once you add this you can add the class / color to the table. There are two tables that A+ generates, a weekly calendar using get_monthly_calendar( ) and a monthly calendar using get_weekly_calendar( ) lines 1973, 2271 in appointments.php . Minor modifications here can add the fourth color to the table.

    This is also where you can add the disable blocking logic if you want

    Hope that helped


  • Peter

    Hello Jude,

    Many thanks for pointing to the right direction, that helped much. I also followed your path and I think I have my first alfa version of this working. But there is one problem I had to fight and that is to rewrite most of the "is_possible" function because this one is mixing in the code many different time checks, so only adding 4th color caused many different non-working hours to use this color, not only my "free, but collision ones". (check attachment Capture_no_is_possible_split.png.

    Picture explanation:
    - white : free
    - black: not-possible
    - orange: existing appointment
    - the 4th color is the pink one in my test which I wanted only to block times too soon before next appointment for the selected service duration
    - Base time: 30min, selected service is 60min long
    - Saturday in the shown weekly calendar is non-working hours after 13:00
    - Sunday is non-working

    So I played a little with the code and split the "is_possible" functions into two different functions called "is_possible" and "is_service_outside_working_hours" and the final result is now as I wanted (see Capture_is_possible_functionality_split_and_tweeks.png).

    I will make this a feature request because this thing adds a very nice feature with only relatively small coding work (attached a txt file with my changes documented and also my appointments.php to run diff against the official one). It is definitely not heavily tested yet, but if some dev here finds it interesting to integrate (after making it much nicer) I would love having this after next release so that I do not have to do code editing again on top of another new code.

  • Jude

    Hey Peter

    Thanks for posting back code that can improve the plugin.

    I'll try and debug the is_possible() function when I find the time. We'll leave the code here for now and if a lot of our members start using it, we will definitely consider making it part of our code.

    We may need to polish it a bit before adding it into the codebase but Great Stuff. Thanks again for your efforts :slight_smile:


  • Peter

    Hello Jude,

    I am not naive to think that my dirty 20min code hack will get to the official release in the state I shared :slight_smile:

    My code is definitely not fit for integration in the state right now as I am not using/tested all the function of A+ to know if I break something (like the overtime allowing, etc... ). Also if you go this way with splitting the is_service_possible function, then my current two clones of this function (is_service_outside_working_hours) definitely need a makeover as now there is a lot of copy&pasted code in these two that needs streamlining or exporting to a third function.

    Many thanks for your support so far (moving to the email attachments now from the other topic)

    PS: Just noticed that my appointment.php attachment was blocked by forum, so attached here my current working appointments.txt (only changed extension).

    PPS: txt blocked, zip blocked, 7z blocked. How to practically share php files with people on this forum?

  • Jude

    Many thanks for your support so far (moving to the email attachments now from the other topic)

    Sure, I am looking into that thread as well so let me know if you need anything

    PPS: txt blocked, zip blocked, 7z blocked. How to practically share php files with people on this forum?

    Zip should work fine, as long as you remove the .php extension. This is one of those safety measures, where safe is better than sorry :slight_smile:

  • Peter

    Hello Jude and Hello scott,

    To avoid all the restrictions here on forum, here are the two files I modified to achieve this 4th color for my use via direct url download link.



    @scott, after extracting them from the 7z compression, replace them inside your wp-content/plugins/appointments and wp-content/plugins/appointments/includes. The 4th color is configurable under settings. PLEASE NOTE THIS IS ONLY MY PERSONAL EXPERIMENTAL implementation, do not consider this official or tested yet.

    I also recommend that you test this first on non-production system :wink:

    if you can, download the two files and place them in the forum as your post attachments, I do not want to (and is probably against license) to have these files under direct url link as I used here. Once you do that I will remove the files from the url. Thanks!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.