A client of mine is using the Yith WooCommerce booking plugin on a WordPress / WooCommerce installation.
And he wants to connect it with an external program he uses, I am stuck at the creation of a new booking that comes from his program.
The booking is created successfully, and the backend sees it as all, but the front-end Ajax calendar on the products page is not refreshing and shows the old availability.
A demo part of my code is below:
$booking = get_post(5404);
$booking->post_status = 'bk-cancelled';
wp_update_post($booking);
$GLOBALS['wpdb']->update( $GLOBALS['wpdb']->posts, $booking, array( 'ID' => 5404 ) );
clean_post_cache( 5404 );
do_action( 'yith_wcbk_booking_updated', $booking );
do_action( 'yith_wcbk_update_booking', 5404, $booking );
$booking = yith_get_booking( $booking );
$booking->save();
At this step, I am trying to update programmatically the status of an existing Yith WooCommerce booking to cancelled and although it works on the back end at the product page it does not clear the dates.
Any thoughts?
Try the following simplified code version, using available Yith WooCommerce Booking methods:
It should work and solve your issue.
Found documentation: