Title: The WC function does not work
Last modified: December 6, 2021

---

# The WC function does not work

 *  Resolved [denism300](https://wordpress.org/support/users/denism300/)
 * (@denism300)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/the-wc-function-does-not-work/)
 * The function WC_Query::get_main_search_query_sql() does not work on search page.
   It return empty result, but if I remove the argument dgwt_wcas=1 from the browser’s
   address bar, the function works correctly

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Kris](https://wordpress.org/support/users/c0nst/)
 * (@c0nst)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/the-wc-function-does-not-work/#post-15139819)
 * Hi [@denism300](https://wordpress.org/support/users/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
 *  Thread Starter [denism300](https://wordpress.org/support/users/denism300/)
 * (@denism300)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/the-wc-function-does-not-work/#post-15146141)
 * Hello [@c0nst](https://wordpress.org/support/users/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
 *  [Kris](https://wordpress.org/support/users/c0nst/)
 * (@c0nst)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/the-wc-function-does-not-work/#post-15157251)
 * Hi again [@denism300](https://wordpress.org/support/users/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.wordpress.org/reference/hooks/posts_search/](https://developer.wordpress.org/reference/hooks/posts_search/)
 * Regards,
    Kris
    -  This reply was modified 4 years, 6 months ago by [Kris](https://wordpress.org/support/users/c0nst/).
 *  Thread Starter [denism300](https://wordpress.org/support/users/denism300/)
 * (@denism300)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/the-wc-function-does-not-work/#post-15157276)
 * ok, thanks!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘The WC function does not work’ is closed to new replies.

 * ![](https://ps.w.org/ajax-search-for-woocommerce/assets/icon-256x256.png?rev=
   2883754)
 * [FiboSearch - Ajax Search for WooCommerce](https://wordpress.org/plugins/ajax-search-for-woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ajax-search-for-woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ajax-search-for-woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/ajax-search-for-woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ajax-search-for-woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ajax-search-for-woocommerce/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [denism300](https://wordpress.org/support/users/denism300/)
 * Last activity: [4 years, 6 months ago](https://wordpress.org/support/topic/the-wc-function-does-not-work/#post-15157276)
 * Status: resolved