I added the following code to a php widget on my site in order to search the site by product category via a drop down box.
<form role="search" method="get" id="searchform" action="<?phpbloginfo('siteurl'); ?>"<div>
<label class="screen-reader-text" for="s">Search for:</label>
<input type="text" value="" name="s" id="s" />
<?php wp_dropdown_categories ($args = array(
'taxonomy' => 'product_cat',)); ?>
<input type="submit" id="searchsubmit" value="Search" /></div></form>
I can’t figure out why any the search isn’t returning any hits. When I look at the search results something seems off. I see only the search term and the category number (example=”?s=flour&cat=17″) Any guidance on where to start reading is most appreciated.
By default WordPress doesn’t search custom post types when a search query is performed, to solve the issue you are facing, add the following hidden field to your widgets form definition
<input type="hidden" value="product" name="post_type">
Use pre_get_posts filter to change the search query
For more information please check below link
https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts