Woocommerce Booking - get the earliest reservation date

92 Views Asked by At

i using woocommerce booking and i need to show on product page earliest reservation date ..

Nearest available date: July 25, 3 p.m

I is possible?

I try do this, but doesnt work

<?php
$product_id = get_the_ID();

if (class_exists('WC_Product_Booking')) {
    $booking = wc_get_product($product_id); 

    if ($booking instanceof WC_Product_Booking) {
        $next_availability = $booking->get_availability();

        if ($next_availability) {
            $booking_date = $next_availability['date']; 
            $booking_date_formatted = date_i18n('j. n. Y', strtotime($booking_date)); 
            $booking_time = $next_availability['time']; 

            echo 'Nejbližší dostupný termín: ' . $booking_date_formatted . ' od ' . $booking_time;
        } else {
            echo 'There are no available dates.';
        }
    } else {
        echo 'This product is not bookable.';
    }
} else {
    echo 'The WooCommerce Bookings plugin is not activated.';
}
?>
0

There are 0 best solutions below