Hooks

Hi Guys,

I’ve added Appointments+ and I think it does just about exactly what I want. However I was wondering what hooks are available? I would like to be able to change the duration display on the user confirmation from minutes to hours. Is this possible?

Thanks.

  • Hakan
    • The Incredible Smush

    Hi,

    There are about 100 hooks that are sufficient for most of the customisations. We are adding new ones with new releases as they are asked and required.

    I am providing examples (or exact codes) for using such hooks, but you can also search for them inside the codes (with apply_filters and do_action keywords) or search in the forums for a similar application.

    For example your specific need has been answered recently:

    https://premium.wpmudev.org/forums/topic/time-base-minutes#post-307230

    function convert_to_hour( $text, $duration ) {
    if ( $duration < 60 ) return $text;
    $hours = floor($duration/60);
    if ( $hours > 1 ) $hour_text = ' hours ';
    else $hour_text = ' hour ';
    $mins = $duration - $hours *60;
    if ( $mins ) $min_text = $mins . ' minutes';
    else $min_text = '';
    return $hours . $hour_text . $min_text;
    }
    add_filter('app_confirmation_lasts', 'convert_to_hour', 10, 2);

    For attachments please see the original post.

    In case of more demanding applications it is always possible to use $appointments object in your functions.php. For example, changing the appointment status in case a payment action hook from a 3rd party plugin:

    function my_handle_status( $app_id ) {
    global $appointments;
    $appointments->change_status( 'paid', $app_id );
    }
    add_action( 'action_after_payment', 'my_handle_status" );

    Cheers,

    Hakan

  • chrisdrake
    • New Recruit

    Thanks guys, very helpful.

    I’m pretty comfortable writing functions for wordpress, but before I start I would like your opinion on whether you think the following modifications are possible using the available hooks;

    – Prevent an appointment being booked within 24 hours before the appointment start.

    – Set a fixed start time for a service.

    – Make a service unavailable between a set date range.

    Thanks!

    Chris

  • Hakan
    • The Incredible Smush

    Hi,

    You can use the following hooks:

    Prevent an appointment being booked within 24 hours before the appointment start.

    app_is_holiday

    Set a fixed start time for a service.

    app_schedule_starting_hour

    Make a service unavailable between a set date range.

    Again app_is_holiday

    Cheers,

    Hakan

  • chrisdrake
    • New Recruit

    Thanks again Hakan.

    I was wondering if you could help me with one more thing which I’m struggling to find in appointments.php?

    I need some of my services to start at 8:00am, and some to start at 8:30am. I’m guessing my function would look something like this but I can’t find out how to get the service ID;

    add_filter( 'app_schedule_starting_hour', 'custom_starting_hour' );

    function custom_starting_hour( $start ) {
    $earlyServices = array( 1, 2, 3, 5);

    if ( in_array( get_service_id(), $earlyServices ) {
    return 8.00;
    } else {
    return 8.50;
    }
    }

    Thanks,

    Chris

  • Hakan
    • The Incredible Smush

    Hi,

    To get the service ID you can use:

    global $appointments;
    $service_id = $appointments->get_service_id();

    Instead of changing starting time, you may think to set 8-8:50 as non-working. It is more flexible and it already includes service_id.

    Check this thread which has similar requirements:

    https://premium.wpmudev.org/forums/topic/how-to-have-some-appointments-start-at-0x15am-some-days-and-others-0x00am

    Cheers,

    Hakan

  • Brian Purkiss
    • Smushie Pies

    We hope you were able to resolve this. Since this thread has been inactive for some time I am going to go ahead and close the ticket. If you were unable to resolve it or have any further questions, please feel free to re-open the ticket – we are more than happy to help!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.