Appointments legacy time calculus ignores padding

Our site has multiple providers and multiple services. Some of the services have a 15 minute padding afterwards.

We have found that if we set the time slot calculus to "Minimum time based appointment duration calculus (legacy)," it ignores the padding and allows appointments to be scheduled immediately after the previous appointment.

We were avoiding the problem by setting the time slot calculus to "Service duration based calculus." But now we have noticed that available start times are changing depending on the duration of the appointment being scheduled.

According to this forum post https://premium.wpmudev.org/forums/topic/starting-appointment-time-dependent-on-duration-of-appointment-why we understand that we should change to the legacy time calculus. How can we do that and still keep the service padding?

  • Vaughan

    Hi Lisa,

    Hope you're well?

    The padding works best using non-legacy calculus, this is a known limitation with the padding. We are hoping to address this in a future update, but I can't give an ETA at this time.

    in legacy mode, you might need to set the length of the service to include the padding time itself. You could add a note explaining that the appointment length includes additional time perhaps?

    Hope this helps

  • pxwm

    Hi @Vaughan - I hope you don't mind me chiming in

    Hi @Lisa Linn

    To add to @Vaughan suggestion of adding the 15mins to the Service duration you can add some bespoke code to your functions.php.

    So let's say your Service duration times are 30mins, 45mins, 60mins.
    Then adding the 15mins padding to your Service duration time they now become: 45mins, 60mins, 75mins.

    This would work fine but will display the new Service duration times in the Booking form and as @Vaughan has indicated you could add a note on the Appointment page.
    .
    However as an alternative adding the bespoke code would enable you to display the Service duration times minus the 15min padding so even though A+ is blocking out 45mins, 60mins, 75mins in the backend the code will display the 'real' Service duration time of 30mins, 45mins, 60mins in the booking form.

    If you think this would help please let me know and I will post the bespoke code for you to try.

    I hope this helps
    Regards
    SteveB

  • Vaughan

    Hi Lisa,

    I'm aware of the custom code Steve @pxwm is referring to, it's been a long while since I seen it though, so I can't recall whether it was done with a filter or directly in the plugin. If it's done with a filter, then future updates will not affect it at all :slight_smile:

    Either way though, i'm almost pretty sure with some slight modification, we could add conditional checks to it, so it only applies the subtraction for specific services only.

    Thanks

  • pxwm

    Hi @Lisa Linn

    I can confirm that the bespoke code is added to the functions.php (theme file) so it will not be affected if the A+ plugin is updated.

    Currently it doesn't include a filter for specific Services but this should not be an issue.

    Is it possible you could provide the following information and then we can revise the bespoke code:-

    1) The Service ID for each 'Service' you wish to extend by 15mins. The Service ID can be found by logging in to the Wordpress dashboard as Admin then Selecting A+ Settings then the 'Services' tab. The ID is on the far left.

    Regards
    SteveB

  • pxwm

    Hi @Lisa Linn

    I'm pleased to confirm I've added some bespoke code to our demo site and tested and it seems to work fine.

    I've set our demo site as follows:-

    Shows 15 min Time slot intervals in the scheduler

    Service1 = 15mins without 15 min padding
    Service2 = 30mins with 15mins padding
    Service3 = 45mins without 15 min padding
    Service4 = 60mins without 15 min padding
    Service5 = 70mins without 15 min padding

    Service Provider 1 to 8 with WHrs as 09h00 to 17h00

    Therefore if you book any Service selecting any Service Provider the Booking form will correctly show the actual duration of the Service and will block out the time slot(s) based on the duration of the Service except for Service2 that will show 30mins in the Booking form but will block out 45mins

    Therefore please feel free to book some appointments on our demo site and then check how many 15min time slots have been blocked out.

    If this meets your requirements I'll provide you the bespoke code based on your Service IDs

    To test select: http://appoint3.pxwm.co.uk/ and then the APPOINTMENTS (MONTHLY) page

    Please let me know how you get on

    Regards
    SteveB

  • Lisa Linn

    Hi Steve, we've tested your sample page and it works great. However I have had one change from the site owner: she wants one service to have a *30* minute padding, and others to have 15 minutes.

    I apologize for the last-minute change, I realize this is not what we originally told you. Is it possible to do this? These are the services that would be affected:

    20 = 15 minute padding
    21 = 15 minute padding
    22 = 30 minute padding
    33 = 15 minute padding
    All other services = no padding

    Let me know if this is possible. Thank you!

  • pxwm

    Hi @Lisa Linn

    I'm pleased it worked.

    I'm pleased to confirm I've revised the code to meet you slightly revised set of requirements and I've added the revised code to our demo site and tested and it seems to work fine.

    I've set our demo site as follows:-

    Shows 15 min Time slot intervals in the scheduler

    Service1 = 15mins without 15 min padding
    Service2 = 30mins with 15mins padding
    Service3 = 45mins with 30 mins padding
    Service4 = 60mins without 15 min padding
    Service5 = 70mins without 15 min padding

    Service Provider 1 to 8 with WHrs as 09h00 to 17h00

    Therefore if you book any Service selecting any Service Provider the Booking form will correctly show the actual duration of the Service and will block out the time slot(s) based on the duration of the Service except for:-

    1) Service2 that will show 30mins in the Booking form but will block out 45mins

    2) Service3 that will show 45mins in the Booking form but will block out 75mins

    Therefore please feel free to book some appointments on our demo site and then check how many 15min time slots have been blocked out.

    If this meets your requirements I'll provide you the bespoke code based on your Service IDs

    To test select: http://appoint3.pxwm.co.uk/ and then the APPOINTMENTS (MONTHLY) page

    Please let me know how you get on

    Regards
    SteveB

  • pxwm

    Hi @Lisa Linn,

    I'm pleased to attach the code at the bottom of this post for you to test and confirm it works as per your requirements.

    I always recommend before adding any bespoke code that you:-

    1) Take a full back up of the website including the database.

    Once you have completed the back up you need to:-

    1) Login to the Wordpress dashboard as Admin
    2) Then hover over 'Appearance' from the left hand menu and select 'Editor'
    3) Then scroll down and locate 'Theme Functions - functions.php' in the right hand templates list
    4) Then select this file
    5) Then scroll to the very bottom of the code and you should see ?> which is the end of the php code.
    6) You then need to add the bespoke code directly above ?>
    7) Then click 'Update file'
    8) Once added successfully select 'Appointments' and 'Settings' from the left hand menu
    9) Then select the 'Services' tab
    10) Then add 15mins to the duration of 'Services' ID 20, 21 and 33
    10) Then add 30mins to the duration of 'Services' ID 22
    11) Then click 'Save Services'
    12) Then test to confirm it all works as required.

    function modify_duration_text( $text, $duration ) {
    	global $appointments;
    	if (($appointments->service == 20) || ($appointments->service == 21) || ($appointments->service == 33)) {
    		return ($duration - 15) . ' minutes';
    	} elseif ($appointments->service == 22)  {
    		return ($duration - 30) . ' minutes';
    	} else {
    		return $duration . ' minutes';
    	}
    }
    add_filter('app_confirmation_lasts', 'modify_duration_text', 10, 2);

    Please let me know how you get on
    Regards
    SteveB

  • Vaughan

    Hi

    @pxwm This is awesome work you have done here steve, I think we've said it many times before, but i'll say it again, we can't thank you enough for all the help you provide & have provided here in the past, especially with Appointments+ plugin. i'm sure the members you have have helped will all say the same. If we ever meet up at a wordcamp or elsewhere, feel free to remind me I owe you a lot of beers :wink:

    Cheers.