Only one date selection in search


Is it possible that user could only select one date, and it wouldn’t require / recommend to select multiple dates for the search for bookable available listings? As now user can select multiple dates to search listings. We would need these two options:

  1. Select only one date in search form
  2. Do not allow to select dates in listing booking, as our priority is now to only let user to see what dates are available for that specific listing, but we won’t let him to book these dates for now.

Is it possible to do these two functionalities?

If there’s a single date per listing you can try using a custom Date attribute instead of bookings, to indicate this date on the listing page and allow searching listings by a specific date. Switching the date range search to date only and disabling bookings while displaying the availability is possible, but requires code customizations.

Could you explain please what do you mean with single date per listing? And are there any snippets for disabling bookings / and to allow only one day selection in search?

If you don’t need the booking features please try to disable the HivePress Bookings extension in WordPress/Plugins. Then you can add a custom Date attribute in Listings/Attributes, mark it as Editable and Required, set the Date Range search type for it, mark it as Filterable etc. This way there will be a single unique date for listings that can be set in the listing edit form and it’ll be possible to search listings based on this date.

But will there also be possibility to mark available / not available dates for vendor? Similar to functionality that there is in bookings, where user can select dates in his calendar and disable them.

In this case please consider using Bookings because attribute allows saving a single date per attribute only. With Bookings vendors can block specific date ranges in the calendar, also set the booking offset and window to control how far users can book in advance and the minimum delay until the first date available for booking.

Yes, so as I understood we still need to use bookings, but is there any simple snippet which could disable possibility to select multiple dates in search?

Yes, it may be possible with a snippet but please describe the use-case for this - with a single date selection users would have to change the date and click Search for every date, with a date range they can search (for example) all listings available for a specific week or month.

In the search bar user now can select date range from day till other day, what we need is for user to give ability to select only 1 date, not multiple ones. So when user selects one date, listings with that selected day would appear. Basically we need to disable multiple dates selection and show listings that are available on that selected day.

Sorry for the delay.

Unfortunately there’s no simple solution because the search function expects a date range - I recommend keeping it as is if you have at least a few users that would want to search listings by a few dates (e.g. if they don’t know the exact date they need).

You can also try using this snippet, it reduces the maximum date range selection in search to 1, you can add it via the Code Snippets plugin:

	function ($form){
			$form['fields']['_dates']['max_length'] = 1;
		return $form;

Thank you, I have done everything to work using some Javascript. The only question I have left is it possible to change data-mode from range into single with snippet? As the problem is if i change it with Javascript it still doesn’t react as single date picker, as page loads it as range mode and than it changes into single one. Maybe it would possible to change this code part with snippet so it wouldn’t override existing range value?

Sorry, there’s no simple code snippet - this requires advanced customizations.

If customizations are required for your site, please try customizing it using the collection of code snippets Search · user:hivepress · GitHub and other developer resources, or consider hiring someone for custom work

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