0.00  View Cart

Support WooCommerce Easy Booking Sold Out Reporting Info

This topic contains 1 reply, has 2 voices, and was last updated by  Ashanna 5 months, 2 weeks ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #5493

    Hybrid AWD

    I know I can view the availability of an item under Reports but is there any potential way to export or see some sort of report that would show an inventory level going to zero?

    I’m trying to make a good observation on what items we should carry more of for our rentals and going through each of the top performing items isn’t bad but I may be overlooking other items. We have quite an extensive inventory so doing each item separately really isn’t effective and hopefully there is a way we can pull that info.


    Plugin's author


    You can try this:

    • Create a file named outofstock.json in your theme folder (child theme if you have one).
    • Add this code to the theme’s functions.php file:
    add_action( 'easy_booking_save_settings', 'export_out_of_stock_products', 10 );
    function export_out_of_stock_products() {
        $booked_items = ebac_get_booked_items_from_orders( true );
        $out_of_stock = array();
        foreach ( $booked_items as $product_id => $booking_data ) {
            $product = wc_get_product( $product_id );
            if ( ! $product ) continue;
            foreach ( $booking_data as $index => $data ) {
                $product_stock = $product->get_stock_quantity();
                $qty_booked = $data[2];
                $stock_lvl = $product_stock - $qty_booked;
                if ( $stock_lvl <= 0 ) {
                    if ( ! isset( $data[1] ) ) {
                        $out_of_stock[$product_id][] = array( $data[0] );
                    } else {
                        $out_of_stock[$product_id][] = array( 'from' => $data[0], 'to' => $data[1] );
        $fp = fopen( get_stylesheet_directory() . '/outofstock.json', 'w' );
        fwrite( $fp, json_encode( $out_of_stock ) );
        fclose( $fp );

    Then save Easy Booking settings and you should have everything exported to the outofstock.json file.

    You should get an array of each product ID with the dates that out-of-stock. If it’s compressed, you can use http://jsonviewer.stack.hu/ to make it more readable.

    Please note that it works on my test website, but I’m not sure it will on yours as you have a lot of products and orders and I’m afraid the request will be too heavy (and remember to always make a backup of your website before doing something like this).

    I hope this helps.


Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.