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?
1条回答 默认 最新
- dsn1327 2015-07-17 09:41关注
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.
解决 无用评论 打赏 举报
悬赏问题
- ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
- ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
- ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
- ¥15 如何在炒股软件中,爬到我想看的日k线
- ¥15 seatunnel 怎么配置Elasticsearch
- ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
- ¥15 (标签-MATLAB|关键词-多址)
- ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
- ¥500 52810做蓝牙接受端
- ¥15 基于PLC的三轴机械手程序