• Hi friend, thanks for your plugin! i tried to integrate search by SKU for woo, but then i found your plugin. I did small improvement to your code, so now we can search products by SKUs also, i would like that you will add it to your code, so we’ll not lose it with next update:)
    i did change in dropdown_fields() function
    and replaced your query:

    	public function dropdown_fields() {
    global $wpdb;

    $status = apply_filters( 'wfobp_product_status', 'publish' );
    $sql = "SELECT p.ID AS product_id, p.post_title AS product_title, pm.meta_value AS product_sku
    FROM $wpdb->posts as p
    LEFT JOIN $wpdb->postmeta as pm ON pm.post_id = p.ID
    WHERE p.post_type = 'product'
    AND pm.meta_key = '_sku'";
    $sql .= ( $status == 'any' ) ? '' : " AND post_status = '$status'";
    $all_posts = $wpdb->get_results( $sql, ARRAY_A );

    $fields = array();
    $fields[0] = esc_html__( 'All Products', 'woocommerce-filter-orders-by-product' );
    foreach ( $all_posts as $all_post ) {
    $fields[ $all_post['product_id'] ] = $all_post['product_title'] . '(' . $all_post['product_sku'] . ')';
    }

    return $fields;
    }

    You used select2 search for dropdown, so now we have sku in product name and we easily can search product by typing SKUs in search dropdown 🙂

  • You must be logged in to reply to this review.