More about search suggestions feature.
Starting from Advanced Woo Search PRO version 3.23, you can show search suggestions to your shop users.
Search suggestions will show some suggested search terms based on the current search query and products currently available for your WooCommerce store.
Example: a user searches for Hoodies
. As a search suggestion, they can see terms like Yoga hoodies
, Full-zip hoodies
, V-Neck hoodie
, etc.
Search suggestions are a very powerful feature. They help shop customers find more related products, promote different products, and make search queries more specific to find exactly the needed products for every user.
To start using the search suggestions feature, first make sure that it is enabled. It is disabled by default.
So open the plugin settings page -> Search Suggestions page and turn on the Enable suggestions
option.
After this, suggestions will immediately display for users' queries.
Clicking on each search term will force the plugin to re-trigger AJAX search. You can change this behavior from the settings page and instead redirect users to the search results page for new selected search terms.
Note: Search suggestions cannot be displayed for all search queries. Sometimes there are just no similar terms across shop products to generate any suggestions at all.
Also worth mentioning is that enabled search suggestions will only be available for AJAX live results. Want to display them on the search page too? This is also possible—just check the topic below.
The search suggestion feature has a variety of different options. We will cover all of them below.
Go to the plugin settings page -> Search Suggestions tab to view all available options related to search suggestions.
Here is the list of all available options and their descriptions.
Enable suggestions
- Enable/disable search suggestions. Default = Off
Display layout
- Choose one of the pre-defined layouts for search suggestions.
Max number of suggestions
- Maximum possible number of generated search suggestions per search. Default = 6
.
Max words per suggestion
- Maximum number of words per search suggestion. Default = 5
Sources
- Product fields used to generate search suggestions. Default = Product title
Show only when no results
- Show search suggestions only when the current search returns no results. Default = Off
On click
- Behavior when a user clicks on a search suggestion item. Default = Trigger AJAX search
By default, search suggestions are visible only inside live AJAX search results.
If you want to show them on the search results page too, you need to use a special shortcode for this.
The shortcode for search suggestions looks like this:
[aws_search_suggestions]
And here is how it can look inside the search page.
Why are search suggestions not displayed on the search results page by default?
This is because Advanced Woo Search doesn't have its own search results page. Instead, it uses your current theme's WooCommerce products search results page template to inherit its search results.
So if you want to additionally show search suggestions, you need to add a special shortcode inside that page template.
How to find that page and how to add that shortcode depends on your current theme and plugins.
If, for example, you are using a plugin like Elementor, then simply open the template for product search results and add the shortcode inside it.
Another solution is to use a text widget and add the shortcode inside it. You just need to find the needed widget area (if your theme has such) and add a text widget with the shortcode inside it.
Another more advanced solution is to use PHP code. If you know where exactly you need to add the shortcode inside the theme PHP file, just use the following snippet:
echo do_shortcode('[aws_search_suggestions]');
Note: Search suggestions will only be visible inside WooCommerce product search results pages. If you try to add that shortcode to any other page, it just won't be displayed.
More about all available plugin shortcodes can be read here: Shortcodes.
Q: Can I edit search suggestions options via a PHP hook?
Yes, it is possible by using the aws_suggestions_params
hook. For example, we want to display a maximum of 4 search suggestions. The code snippet will look like this:
add_filter('aws_suggestions_params', 'my_aws_suggestions_params', 10, 2); function my_aws_suggestions_params($params, $data) { $params['max_number'] = 4; return $params; }
This will overwrite plugin options and values from shortcodes.
Q: Can I edit search suggestions results output?
Yes, you can do this by using the aws_suggestions_results
PHP hook. It returns an array of search suggestions that you can edit.
Example of use:
add_filter('aws_suggestions_results', 'my_aws_suggestions_results', 10, 2); function my_aws_suggestions_results($suggestions, $data) { $suggestions[] = 'My new suggestion'; return $suggestions; }
Q: Can I disable all product search results and show only search suggestions?
Yes, it is possible. First, disable all Archive pages
search from the plugin settings page. Second, use the following code snippet:
add_filter('aws_search_results_products_ids', 'my_aws_search_results_products_ids', 999); function my_aws_search_results_products_ids($ids) { if (is_ajax()) { $ids = array(); } return $ids; }
Now live search results will only display search suggestions. The search results page will still display all available search results.