• Resolved pgierak

    (@petergierakgmxde)


    Hey together I am facing a problem and cannot find any solution.
    Sadly my programming skills are not the best to fix it by myself.

    I installed the plugin in free version and also added the extension to the functions.php for WooCommerce Bookings, which is working totally fine.

    But I cannot Filter orders by: “Booking Start Date” instead of the “Order Date” which I need in my case, because I need every day an exported list of bookings with Start Date from the current day, and therefore the “Order Date” makes no sense.

    Is there any option to extend the Filter order by section with this field “Booking Start Date”, it is already perfectly working in the “Sort order by” section.

    Thx for help!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author algol.plus

    (@algolplus)

    hi

    You should set booking start date in “Date Range” (1st field)
    and add following PHP code section “Misc Settings” .

    // you should set booking start date in "Date Range" (1st field)
    //remap settings
    add_filter('woe_settings_validate_defaults', function($settings){
        if($settings['from_date']) {
            $settings['book_start'] = date("Ymd", strtotime($settings['from_date']));
            $settings['from_date'] = "";
        }
        return $settings;
    }); //filter orders
    add_filter( 'woe_sql_get_order_ids_where', function($where, $settings ){
        global $wpdb;
        $where[]= "orders.ID IN ( SELECT DISTINCT post_parent FROM {$wpdb->posts} WHERE ID IN (SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key='_booking_start' AND meta_value LIKE '{$settings['book_start']}%'))";
        return $where;
    },10,2); //filter order items
    add_filter( 'woe_skip_order_item', function($skip, $product, $item, $item_meta, $post ){
        global $wpdb;
        $booking_id = $wpdb->get_var( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key= '_booking_order_item_id' AND meta_value=" . intval( $item->get_id() ) );
        if( $booking_id ) {
            $book_start_time = $wpdb->get_var( "SELECT meta_value FROM {$wpdb->postmeta} WHERE meta_key= '_booking_start' AND post_id=" . $booking_id );
            // it's string in format 20200601000000
            if( substr($book_start_time,0,8) !=WC_Order_Export_Engine::$current_job_settings['book_start'])
                $skip=true;
        }
        return $skip;
    },10,5);
    Thread Starter pgierak

    (@petergierakgmxde)

    Thx for fast answer!!
    It is working now as I want to have it ??
    Great support *thumbsup*

    Plugin Author algol.plus

    (@algolplus)

    You’re welcome

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Extend filter orders by with “Booking Start Date”’ is closed to new replies.