I'm trying to customize the booking experience. My products are tours spread over the year and scrolling through the calendar to find an available day isn't efficient. What I want is a drop down list that has the next available day for that tour. Is there any plugin or solution for my situation?
Hi The file is located in wp-content/plugins/woocommerce-bookings/templates/booking-form
The code in the post described works for the most part but there are some errors
Warning: reset() expects parameter 1 to be array, string given in /home/betaacademyofflo/public_html/wp-content/plugins/woocommerce-bookings/templates/booking-form/date-picker.php on line 54
Warning: Variable passed to each() is not an array or object in /home/betaacademyofflo/public_html/wp-content/plugins/woocommerce-bookings/templates/booking-form/date-picker.php on line 55
This error appears for every date available.
A tweak that I am trying to make is that currently the select list shows duplicates of each date I need it to just show the date once.
By each date once I mean just the start date my bookings have the same start and end date.
You can see an example here example list I have suppresed the errors for now. heres the code so far pretty much the same as the OP version on wordress support.
<?php
$year = array();
$month = array();
$days = array();
$s;
$day1;
$i=0;
$j=0;
foreach ($availability_rules as $value) {
foreach ( $value as $value2) {
foreach ( $value2 as $value3) {
reset($value3);
while (list($key, $val) = each($value3)) {
$year[$i] = $key; //add year to array - $i is the count of how many course
reset($val);
while (list($key2, $val2) = each($val)) {
if($key2 < 10){
$month[$i] = '0'.$key2; //add the month value to another array - with leading 0
}else{
$month[$i] = $key2; //add the month value to another array
}
$s = "";
$j = 0;
reset($val2);
while (list($key3, $val3) = each($val2)) {
if($j==0||$j==1){
$s = $s . $key3 .',';
}else{
$s = $s . $key3;
}
if($j==0){
$day1[$i] = $key3; //add the day value to another array
}
$j++;
}
$days[$i] = $s;
}
$i++; //increments each time we loop through a year
}
}
}
}
$arrlength = 0;
$arrlength = count($year); //this is our total amount of courses
?>
<fieldset class="wc-bookings-date-picker <?php echo implode( ' ', $class ); ?>">
<legend><?php echo $label; ?>: </small></legend>
<select id="availableDates">
<option value="">Select Date</option>
<?php
if($arrlength==0){
echo "<option value=''>There are no dates</option>";
}else{
$todays_date = date("d-m-Y");
$today = strtotime($todays_date);
for($total_dates = $arrlength -1; $total_dates >= 0; $total_dates--){ //loop through total amount
$expiration_date =strtotime($day1[$total_dates].'-'.$month[$total_dates].'-'.$year[$total_dates]);
$actualdates = $day1[$total_dates]-$month[$total_dates]-$year[$total_dates];
$displaydates = $day1[$total_dates]/$month[$total_dates]/$year[$total_dates];
//$input = array( $day1[$total_dates]-$month[$total_dates]-$year[$total_dates]);
//$result = array_keys($input);
if ($expiration_date > $today) {
echo "<option value='$day1[$total_dates]-$month[$total_dates]-$year[$total_dates]'>$day1[$total_dates]/$month[$total_dates]/$year[$total_dates]</option>"; //pull in the index for each date array
}
}
}
?>
What I've tried;
Running an extra foreach on the final result did not work tried array_unique did not work
Anny guidance here would be most aprreciated.