问题描述
我正在尝试使用 WooCommerce Bookings 上的 check_availability_rules_against_time
函数来确定是否有时间范围可用于住宿。据我了解,如果根据规则检查的时间段可用,它应该返回 true。我遇到的问题是,如果开始时间可用,即使插槽超出可用性范围,它也会返回 true。
例如,我在产品上有这个范围:
所以我这样测试:
<?PHP
// Query Filter
$args = array(
'post_type' => 'product','posts_per_page' => 20,'tax_query' => array(
array(
'taxonomy' => 'product_cat','field' => 'term_id','terms' => $hotel['cat_habitaciones'],'operator' => 'IN'
))
);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
while ( $loop->have_posts() ) : $loop->the_post();
global $product;
if( ! $product->has_resources() || count($product->get_resources()) == 0 ){
continue;
}
foreach($product->get_resources() as $resource){
echo (WC_Product_Booking_Rule_Manager::check_availability_rules_against_time('2020-04-01','2020-07-01',$resource->id,$product,true)) ? 'Available' : 'Not Available';
}
?>
...html...
<?PHP
endwhile;
} else {
echo __( 'No se encontraron habitaciones disponibles.' );
}
wp_reset_postdata();
所以,上面产品中的这段代码应该返回false,因为根据规则它在5月份停止预订,但它仍然返回true。如果我将开始日期移至 5 月,它将正确返回 false。
你能帮我弄清楚我做错了什么吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)