I made a custom plugin with a custom API endpoint to retrieve WooCommerce booking data.
Currently when I use wc_get_products
I get a 200 status but the array is empty.
How do I tap into WooCommerce?
I've added this to my file:
add_action( 'woocommerce_init', array( 'woocommerce_loaded' ) );
but it does nothing.
When I run this:
function get_data() {
$args = array( 'limit' => -1, 'return' => 'ids', 'type' => 'booking' );
$products = wc_get_products( $args );
return $products;
}
I get back the 11 IDs of the 11 products I have. But no other details? When I remove the IDs and do just 'limit' and 'type', I get back empty availability rules and no other data.
How can I get an array of products returned similar to the WooCommerce API endpoints for product?