I've made a custom plugin with a custom API end point.

I would like to access my bookable products availability times so I can use the API with a react front end.

So far I have this function that my custom endpoint is attached to:

function get_data() {

               $args = array( 'limit' => 1, 'type' => 'booking',  );

               $products = wc_get_products( $args );

               return $products;

When I call my end point in Postman all I get is this:

enter image description here

Why is the array for availability_rules empty and why are there no other details about my bookable product being returned by the WooCommerce wc_get_product() function?

  • I believe that the wc_get_products function just returns default WC_Product objects, disregarding any custom data. Where are the availability_rules stored? In post meta? – Antti Koskinen Feb 14 at 21:21
  • Yeah and thats what I would like, I would like the default WC_Product objects but it returns empty. availability_rules is returned when I specify the type as booking. So surely its a default object too? – kadddeee Feb 14 at 22:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.