Calendar request

Hi,

Is it possible to restrict the user from booking multiple days on the calendar?
I want the user to only be able to select 1 day ( the first day of the booking and then specify how many days the booking will be for).

Thanks

Sorry, there’s no such option at the moment. Please consider using the date range selection instead, this way users can see which dates are blocked. Otherwise, if they select a single date and set different numbers of dates there’s no way to check how many days they can book.

Sorry I explained that wrong.
My bookings are only during one day- no longer than 1 day so I wanted to be able to block the user being able to book any more (as that calculates the price which I’m trying to avoid)

If I could have a snippet that limits a booking to just 1 day that would be ideal.

@yevhen I searched the flatpickr calendar website and found that you can set min and max dates for the calendar…i’m just not sure how to implement this.

Any help appreciated

Please do not edit the core file. Please try to set Maximum Booking Duration for listing. Then users will be able to book only for 1 day

@yevhen setting the max duration to 1 doesn’t work- it only works from 2 and above and that still requires an overnight book witch calculates 2 days amount. I only want one day so the date does not calculate.

I also don’t want the vendor having to set that when adding a listing…this will not work.

It needs to be hard coded in to only let a user select one day (not 2).

Could you please give me a snippet to hard code max booking duration to 1 day if possible. So that a single day/date can only be selected. Then I can hide the field in the form.

Please try switching to Daily bookings in settings, there’s a Nightly mode by default (e.g. for hotel/apartment rentals where 1 day is checking in today and checking out tomorrow). With daily bookings setting the Max Booking to 1 should allow selecting 1 day only.

Also, if you want to enforce this for all new listings please use this snippet to hide the Max Booking field and set it to 1 by default:

add_action('hivepress/v1/models/listing/create', function($listing_id) {
	update_post_meta($listing_id, 'hp_booking_max_length', 1);
});

add_filter(
	'hivepress/v1/forms/listing_update',
	function( $form ) {
		
		// Remove Maximum Booking duration field.
		unset( $form['fields']['booking_max_length'] );
		
		return $form;
	},
	1000
);

That snippet doesn’t work.

It hides the maximum booking duration field but doesn’t set the booking max length to 1.

The setting of 1 doesn’t work.

Try it for yourself.

It was tested locally and it seems to be ok. Please note that this code snippet works only for new listings and restricts new bookings maximum to 1 day. Please try to add a new listing and try to make a booking for this listing

@yevhen ok i disabled other snippets and it now works…however the setting of 1 allows the user to only select an overnight booking, not just single day. I need user to only be aloud to book only on the single day, not overnight into the next day like a hotel reservation. See images:

Actual result:
Screen Shot 2022-06-17 at 6.31.40 AM

Expected result:
Screen Shot 2022-06-17 at 6.32.00 AM

Please make sure that Enable daily bookings setting in HivePress/Settings/Bookings is enabled. Then if a user clicks twice on some date only this date will be chosen

I understand that, that is not what I am referring to. I want to RESTRICT the user from being able to select MORE than a single day. I don’t want the one day for max booking to be overnight booking but just the day itself.

If you set the max booking length to 1 day and daily bookings are enabled then it won’t allow selecting a date range of more than 1 day, but this requires 2 clicks anyway, unfortunately, there’s no temporary fix for this (another workaround would be enabling time slots). We’ll also fix this in the next update, e.g. switching off the date range mode if the max booking length is set to 1 day.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.