Ashanna
3/28/2018 - 6:32 AM

[Easy Booking] Add order status column to the Reports page

[Easy Booking] Add order status column to the Reports page

add_filter( 'easy_booking_reports_custom_columns', 'wceb_custom_reports_column', 10, 1 );

function wceb_custom_reports_column( $new_column ) {
    $new_column[] = array(
        'position' => 0,
        'id'       => 'status',
        'name'     => __( 'Order status', 'easy_booking' )
    );

    return $new_column;
}

add_filter( 'easy_booking_reports_display_custom_column', 'wceb_reports_display_custom_column', 10, 3 );

function wceb_reports_display_custom_column( $output, $column_name, $item ) {

    if ( $column_name === 'status' ) {

        if ( ! empty( $item['order_id'] ) ) {
            
            $order = wc_get_order( $item['order_id'] );

            if ( $order ) {
                return '<mark class="order-status">' . wc_get_order_status_name( $order->get_status() ) . '</mark>';
            }

        }

    }
}