Set a default value for a Booking Slot Duration setting and hide it from listing creation

Hi,

  1. Is it possible to set a default Booking Slot Duration value and hide this field into listing ?
  2. Is it possible to add the “Booking Available From” & “Booking Available To” fields into the listing pages ? I created a check-in & check-out attributes, but for me the “Booking Available From” is similar to the “chek-in” as I used the time values. So how to ask once this value and showing it to the listing pages ?
  3. Related to 2, is it possible to add the “Booking Available From” & “Booking Available To” into the search fields and match with the availability

Thanks,

Hi,

  1. Please try this code snippet How can I set a default value for a listing attribute and hide it from listing creation - #4 by yevhen

  2. If you enabled “per vendor” mode in settings unfortunately there’s no easy way to do this because in this mode all the common booking details are synced with the vendor profile, only the time slot duration and interval can be different (so each listing can be used as a different service, but with a common per-vendor timeline).

  3. Currently there’s no availability search for time-based bookings (we’re working on this feature), but it’s available for date-based ones (a date range field can be added to the search form).

Thank you @ihor !

  1. Thank you !
  2. I didn’t enabled “per vendor” mode in settings. Each bookings have their own value
  3. Can’t wait to see this feature coming

Thank you,
Samir

  1. @ihor Other question about the snippet
    I have an issue on the listing page, the categories are gone, but I have an error message : “the field category is mandatory”
// Remove Category field from listing submit form
add_filter(
	'hivepress/v1/forms/listing_submit',
	function( $form ) {
		unset($form['fields']['categories']);	

		return $form;
	},
	1000
);

// Remove Category field from listing filter form
add_filter(
	'hivepress/v1/forms/listing_filter',
	function( $form ) {
		unset($form['fields']['_category']);	

		return $form;
	},
	1000
);

Other issue with the snippet to set field value. It works when the fields are not hidded, but when I set value + hiding the field it’s not working.

  1. If you mean showing Booking Available To and Booking Available From attributes on the single listing page, then please try this PHP snippet. But please note that it can require further customization. If you are not familiar with the code customization then please consider hiring someone for custom work https://fvrr.co/32e7LvY
add_filter(
	'hivepress/v1/models/listing/attributes',
	function ($attributes){
		if(isset($attributes['booking_min_time'])){
			$attributes['booking_min_time']['display_format'] = '<strong>Booking Available From</strong>: %value%';
			$attributes['booking_min_time']['display_areas'] = ['view_page_secondary'];
		}
		
		if(isset($attributes['booking_max_time'])){
			$attributes['booking_max_time']['display_format'] = '<strong>Booking Available To</strong>: %value%';
			$attributes['booking_max_time']['display_areas'] = ['view_page_secondary'];
		}
		return $attributes;
	},
	1000
);
  1. Please try this PHP snippet to set the default value for the listing category field. Then the previous snippet to hide the category field should work correctly without showing an error
add_action(
	'hivepress/v1/models/listing/create', 
	function($listing_id, $listing) {
		$listing->set_categories(category_id_here)->save_categories();
	}, 
	1000, 
	2
);
2 Likes

Thank you Yevhen, working great !

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