Search bar is not responding

On rare occasions the search doesn’t work properly — customers type in a query and the results are not presented. It might look like something has got stuck, even when they type a query longer than 3 characters. They won’t see any kind of autosuggestions or they might even get a “no-results”.

Here are the main reasons why the search is not working properly:

  • The server returns an incorrect response. This has probably happened if the preloader circles around indefinitely and the search bar does not present any suggestions, as you can see in the GIF.

This issue is often caused by:

  1. One or more security-related plugins are blocking our custom AJAX endpoint; please refer to our documentation and learn how to solve this problem
  2. A PHP fatal error; please head to WooCommerceFiboSearchTroubleshooting tab

Notice: subsequent issues are indicated by the lack of a preloader in the search bar.

  • Deregistered FiboSearch JavaScript file. Sometimes themes or optimization plugins can deregister FiboSearch script. You can check this by typing this line
    jQuery('#jquery-dgwt-wcas-js').length;
    into the console in a web browser of your choice. If the result is “0”, there is a big chance that there is a JavaScript-related error. To load the JavaScript file again, please add this code to your functions.php file:
add_action( 'wp_enqueue_scripts', function() {
    wp_enqueue_script( 'jquery-dgwt-wcas' );
} );
  • Improper embedding of our [fibosearch] shortcode. This shortcode must not be embedded within the <form></form> element. [fibosearch] shortcode itself displays  a <form> element, so adding it within another <form> element will cause a “Double nested form tag” issue and any embedding-related issues might occur. To avoid them, simply embed our shortcode outside any <form> elements.
  • Other issues. If the solutions mentioned in the first two points don’t fix the issues, please use this code:
<?php
add_filter( 'dgwt/wcas/scripts/fixer', function ( $fixer ) {
	$fixer['broken_search_ui_hard'] = true;
	return $fixer;
} );

This snippet activates the Hard mode for fixing the search bar. This solution listens to the DOM elements every second for any changes. The fixer reinitializes all FiboSearch bars on the site every time the search bar is unresponsive.

There are two ways to add this code to your theme:

  1. Open the functions.php file in your child theme and add the code at the end
  2. Or install the Code Snippets plugin and apply this code as a snippet.