Some of my users set a minimum number of booking days for their apartments. The hivepress calendar automatically corrects the number of days, but does not display an error message. The risk is that travelers don’t even realize that the minimum number of days has been changed.
For example, if the traveler indicates a 2-day booking, but the host only offers minimum 5-day bookings, no error message is displayed. Worse still, the reservation calculation amount is randomly incorrect.
Hi,
Please provide more details regarding this issue (e.g., your actions step by step with screenshots, etc.). This will help us to reproduce and resolve the issue faster.
Hi,
I recommend using this feature for this purpose: How to add booking restrictions - HivePress Help Center, therefore, the user will not be able to book fewer days than indicated.
Hi,
I don’t think we understood each other. I already use this option. What I’d like is to display an error message to tell the traveler the minimum number of days if he doesn’t choose the right number.
I’d just like to display an error message like on the screenshot above
Hi,
I tried this, but it doesn’t work :
add_filter(
'hivepress/v1/forms/booking_make/errors',
function ( $errors, $form ) {
$start_date = isset( $_POST['start_date'] ) ? strtotime( $_POST['start_date'] ) : null;
$end_date = isset( $_POST['end_date'] ) ? strtotime( $_POST['end_date'] ) : null;
if ( $start_date && $end_date && $start_date >= $end_date ) {
$errors[] = __('Please note that the selected dates have been automatically modified!', 'text-domain');
}
return $errors;
},
10,
2
);
Hi,
I see. Please try to use this hook: hivepress/v1/models/bookings/errors
, which you can use to check $booking->get_start_time()
, $booking->get_end_time()
and thus prevent the creation of a booking if, for example, less than 5 days are selected Filter: hivepress/v1/models/{model_name}/errors | HivePress Hook Reference.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.