我的目标是创建一个状态为“in-cart”的预订。下面的代码运行良好,创建了具有正确数据的预订。但是当我检查该时间范围内的预订时,创建的预订不存在。我认为这与“get_bookings_in_date_range()”的兑现有关。如果是这样,我如何清除现金?
//This works fine, it returns all the bookingids
$booking_ids = WC_Bookings_Controller::get_bookings_in_date_range($start_date, $end_date, $product_id, true);
//I use insert_post, because create_wc_booking doesnt accept the "in-cart" status
//It creates a booking with the right data
$cart_booking = array(
'post_type' => 'wc_booking',
'post_status' => 'in-cart',
'post_author' => 69,
);
$booking_id = wp_insert_post($cart_booking);
//Updating some data - works
update_post_meta($booking_id , "_booking_product_id", $product_id);
update_post_meta($booking_id , "_booking_start", date("Y-m-d H:i", strtotime($date . $availability[0][0]['from'])));
update_post_meta($booking_id , "_booking_end", date("Y-m-d H:i", strtotime($date . $availability[0][0]['to'])));
update_post_meta($booking_id , "_booking_persons", $personcount);
//Make booking expire after 60 Minutes - works
custom_schedule_cart_removal($booking_id)
//NOW, this booking exists in the backend but doesnt get recognized by the code below, even though it has the right meta-data
WC_Bookings_Controller::get_bookings_in_date_range($start_date, $end_date, $product_id, true);