Hi @denism300
WC_Query::get_main_search_query_sql() returns empty results due to the way of the plugin works. Perhaps we can help solve your problem if you could tell us the context of the use of this function.
Best Regards
Kris
Hello @c0nst
I want to add product filters to the search page, but due to the fact that the function WC_Query::get_main_search_query_sql() returns an empty result, they do not work correctly
Hi again @denism300
You can try to directly modify the SQL query that is responsible for search results.
To do that you can use the posts_search filter with higher priority than FiboSearch.
Here is how FiboSearch uses this filter (with priority 501):
add_filter( 'posts_search', array( $this, 'searchFilters' ), 501, 2 );
Example how you can use it (you need to check if you are in FiboSearch context):
add_filter( 'posts_search', function( $search, $query ) {
// Interrupt early if you are not in the FiboSearch context
if ( ! ( defined( 'DGWT_WCAS_AJAX' ) && DGWT_WCAS_AJAX ) ) {
return $search;
}
// Place to modify $search by your own rules
}, 502, 2);
You can read more about filtering posts_search here: https://developer.ww.wp.xz.cn/reference/hooks/posts_search/
Regards,
Kris
-
This reply was modified 4 years, 6 months ago by
Kris.