Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First day and last day of date picker are shown available #347

Open
cristianvia opened this issue Jun 13, 2023 · 0 comments
Open

First day and last day of date picker are shown available #347

cristianvia opened this issue Jun 13, 2023 · 0 comments
Labels
priority: low The issue/PR is low priority—not many people are affected or there’s a workaround, etc. type: bug The issue is a confirmed bug.

Comments

@cristianvia
Copy link

cristianvia commented Jun 13, 2023

I have one product and when I am booking it, it shall be shown as booked on the check in day and the check out day

While it's not bookable, the calendar shows the first and last day of the booking as green.

I have tried to play with the settings and the check-in and check-out times, but haven't succeed.
I am wondering if there is any way of doing what I am asking here. I have found my way directly overriding the function in charge of showing first and last booked day, but I don't want to start tweaking the code and having to re-add it with every update.
So far I have succeed to do it with the following code. But I don't know if this tweak would affect somewhere else, for what I have seen, it shouldn't.
But it would be great if there is a checkbox option officially on the plugin or if there is a way of doing so and I am not aware of it.

Thanks in advance,

private function prepare_fully_booked_start_and_end_days( $booked_data_array, $resource, $day, $which = 'in' ) {
    if ( isset( $booked_data_array['fully_booked_days'][ $day ][ $resource ] ) ) {
        if ( 'in' === $which ) {
            $booked_data_array['fully_booked_start_days'][ $day ][ $resource ] = $booked_data_array['fully_booked_days'][ $day ][ $resource ];
        } else {
            $booked_data_array['fully_booked_end_days'][ $day ][ $resource ] = $booked_data_array['fully_booked_days'][ $day ][ $resource ];
        }
        // Don't unset the day from fully_booked_days array
    } else {
        // If the day already exists fully_booked_start_days at this point,
        // it means it is also a fully booked end day, so reverting it  
        // back to be in fully_booked_days.  
        if ( isset( $booked_data_array['fully_booked_start_days'][ $day ][ $resource ] ) ) {
            $booked_data_array['fully_booked_days'][ $day ][ $resource ] = $booked_data_array['fully_booked_start_days'][ $day ][ $resource ];
            unset( $booked_data_array['fully_booked_start_days'][ $day ][ $resource ] );

            if ( empty( $booked_data_array['fully_booked_start_days'][ $day ] ) ) {
                unset( $booked_data_array['fully_booked_start_days'][ $day ] );
            }
        }
    }

    // Also removing from partially booked array in case if it  
    // was added there in `move_day_from_fully_to_partially_booked()`.  
    if ( isset( $booked_data_array['partially_booked_days'][ $day ][ $resource ] ) ) {
        unset( $booked_data_array['partially_booked_days'][ $day ][ $resource ] );
    }
    if ( empty( $booked_data_array['partially_booked_days'][ $day ] ) ) {
        unset( $booked_data_array['partially_booked_days'][ $day ] );
    }

    return $booked_data_array;
}
`
@vikrampm1 vikrampm1 added priority: low The issue/PR is low priority—not many people are affected or there’s a workaround, etc. type: bug The issue is a confirmed bug. labels Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: low The issue/PR is low priority—not many people are affected or there’s a workaround, etc. type: bug The issue is a confirmed bug.
Projects
None yet
Development

No branches or pull requests

2 participants