phpwordpresswoocommercewoocommerce-bookings

How do I get all booking dates for a specific product with PHP?


I'm trying to figure out how can I get all booking dates for a specific product - but it seems to be harder than one should think (or maybe it's because I don't know what I'm doing).

I used a couple of hours on it so far, and I'm unable to get anywhere, so far I have tried:

$WCBooking = new WC_Product_Booking('booking');
$WCBooking -> get_bookings_in_date_range($dToday, $dOneYear)
$WCBooking -> get_all_resources_availability($dToday, $dOneYear, $iProductID)

just returns an empty array,

also tried to query all booking posts, but I can't find their start and end date information on them :(

    $aBookings = new WP_Query( 
    array( 
        'post_type' => 'wc_booking', 
        'posts_per_page' => -1 )
    );

What should I try next? I figured it shouldn't be that hard, but I'm not sure where I am going wrong


Solution

  • $aBookings = new WP_Query( 
    array( 
        'post_type' => 'wc_booking', 
        'posts_per_page' => -1 )
    );   
    
    $oCustomPostMeta = get_post_custom($oPost->ID);
    $oCustomPostMeta['_booking_start']
    $oCustomPostMeta['_booking_end']
    

    did the trick, the thing is they saved the post meta as YYYYmmddhhmmss, so just had to split it up first :(