[Appointments+] Option to set the duration of appointments for more than 1 day

Hi, I have a site where I give out appointments that span for more than 1 day. I deal with venues which are given out for 5 days and would want my appointments to run 5 days. As of now I cannot do this.

  • Dimitris
    • Support Star

    Hello there Zen,

    hope you’re having a good day! :slight_smile:

    This would require some extended development to work well, our Second Level Support guys were able to provide a little workaround for this though.

    <?php
    add_action( 'wp_head', function(){
    ?>
    <style type="text/css">
    .app_timetable{
    display: none !important;
    }
    </style>
    <?php
    } );

    add_action( 'wp_footer', function(){
    ?>
    <script type="text/javascript">
    (function($){
    $( document ).ready(function(){
    $( '.app_monthly_schedule_wrapper td' ).on( 'click', function(){

    var ts = $( this ).find( '.appointments_select_time' ).val(),
    target_cell = $( '.app_timetable_' + ts + ' .app_timetable_cell' ).first();
    target_cell.click();

    });
    });
    })(jQuery);
    </script>
    <?php
    } );

    add_filter( 'app_is_holiday', function( $is_holiday, $start, $end, $random, $worker_id ){

    global $wpdb;
    $days_span = 5;
    $range_end = date( 'Y-m-d H:i:s', $start );
    $range_start = date( 'Y-m-d H:i:s', strtotime( "{$range_end} -{$days_span} days" ) );
    $app_table = appointments_get_table( 'appointments' );

    $period_query = "SELECT ID FROM {$app_table} at WHERE 1=1 AND at.start BETWEEN '{$range_start}' AND '{$range_end}'";

    if ( 0 < $worker_id ) {
    $period_query .= "AND worker={$worker_id}";
    }

    $span_results = $wpdb->get_results( $period_query );

    if ( ! empty( $span_results ) ) {
    $is_holiday = true;
    }

    return $is_holiday;
    }, 20, 5 );

    You can insert this exact content into a new MU plugin file, like /wp-content/mu-plugins/app-five-days.php (just create the /mu-plugins/ folder, if it doesn’t exist already).

    In that snippet you will notice a $days_span = 5; line, which represents the 5 days (you can edit this, if you’d like).

    So, after adding this MU plugin, when clicking on a date in the monthly calendar, then the time is being skipped and current service provider is becoming unavailable for 5 days. If you’re having a staging environment for testing, feel free to add it there first and see how that goes. :slight_smile:

    Warm regards,

    Dimitris

  • Zen
    • Happy Helper

    Hello Both and thank you for the events tip. The query is badly written in terms of ‘event’ but it is a close description. It was drafted from a chat and I am so sorry it sounds abrupt.

    I will look again at events to see it fits because in fairness I have not looked at that since any updates for about 12 months and it may work.

    I chose apps as it is for another part of the site that the events not handle at the same time. There was a designated need for a separate part.

    I really value your help – thank you.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.