title: Replace theme search functionality with woocommerce search
body: <p>Is there a way that i can overwrite theme's search query with woocommerce product search. I want instead of search content in pages and post, it will search only in products.</p>
  
  <p>I searched and found this:</p>
  
  <pre><code>    function custom_search_query($where, &amp;$wp_query)
      {
          global $wpdb;
  
          if ( empty( $where ))
              return $where;
  
          // get search expression
          $terms = $wp_query-&gt;query_vars[ 's' ];
  
  
          $where = 'wp_posts.post_type = "product"';
  
          // get searcheable_acf, a list of advanced custom fields you want to search content in
          $list_searcheable_acf = list_searcheable_acf();
          foreach( $exploded as $tag ) :
              $where .= " 
                AND (
                  (wp_posts.post_type LIKE '%$tag%')
                  OR (wp_posts.post_content LIKE '%$tag%')
                  OR EXISTS (
                    SELECT * FROM wp_postmeta
                        WHERE post_id = wp_posts.ID
                          AND (";
              foreach ($list_searcheable_acf as $searcheable_acf) :
                if ($searcheable_acf == $list_searcheable_acf[0]):
                  $where .= " (meta_key LIKE '%" . $searcheable_acf . "%' AND meta_value LIKE '%$tag%') ";
                else :
                  $where .= " OR (meta_key LIKE '%" . $searcheable_acf . "%' AND meta_value LIKE '%$tag%') ";
                endif;
              endforeach;
                  $where .= ")
                  )
                  OR EXISTS (
                    SELECT * FROM wp_comments
                    WHERE comment_post_ID = wp_posts.ID
                      AND comment_content LIKE '%$tag%'
                  )
                  OR EXISTS (
                    SELECT * FROM wp_terms
                    INNER JOIN wp_term_taxonomy
                      ON wp_term_taxonomy.term_id = wp_terms.term_id
                    INNER JOIN wp_term_relationships
                      ON wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
                    WHERE (
                      taxonomy = 'post_tag'
                          OR taxonomy = 'category'                
                          OR taxonomy = 'myCustomTax'
                      )
                      AND object_id = wp_posts.ID
                      AND wp_terms.name LIKE '%$tag%'
                  )
              )";
          endforeach;
          return $where;
      }
      add_filter( 'posts_search', 'custom_search_query', 500, 2 );
  </code></pre>
  
  <p>But this will add advance custom fields in search.. I want to search only for products.</p>
  
  <p>Is that possible?</p>
  
  <p>Thanks in advance.</p>