title: Enable custom taxonomies in WooCommerce product search
body: <p><strong>What I want:</strong> modify the query of the WooCommerce search form (in frontend) to display the products by searching in the name, description and product_tag of the products.</p>
  <p><strong>What I have:</strong> I'm trying with this code <a href="https://stackoverflow.com/questions/11985363/woocommerce-product-search-not-checking-product-tag/56985529#56985529">inspired from this answer</a> that return a result for the name and description of the product. But if i make a search with the tags names, no results. The search query don't search in tags of the product.</p>
  <p>How to reproduce this issue <em>(put the code below in functions.php file of your active theme)</em>:</p>
  <pre><code>function search_product_by_tag( $search, &amp;$query_vars ) {
      global $wpdb, $pagenow;
  
      if ( 'edit.php' == $pagenow || empty($search) ) {
          return $search;
      }
  
      $args = array(
          'posts_per_page'  =&gt; -1,
          'post_type'       =&gt; 'product',
         'meta_query' =&gt; array(
              array(
                  'key' =&gt; 'taxonomy',
                  'value' =&gt; 'product_tag',
                  'field' =&gt; 'name',
                  'terms' =&gt; array($query_vars-&gt;query['s']),
                  'compare' =&gt; 'LIKE',
      )));
      $posts = get_posts( $args );
      if ( empty( $posts ) ) return $search;
      $get_post_ids = array();
      foreach($posts as $post){
          $get_post_ids[] = $post-&gt;ID;
      }
      if ( sizeof( $get_post_ids ) &gt; 0 ) {
          $search = str_replace( 'AND (((', &quot;AND ((({$wpdb-&gt;posts}.ID IN (&quot; . implode( ',', $get_post_ids ) . &quot;)) OR (&quot;, $search);
      }
      return $search;
  }
  add_filter( 'posts_search', 'search_product_by_tag', 999, 2 );
  </code></pre>
  <p><strong>Example:</strong> I've one product : Black Chocolate with the product tag &quot;confection&quot;. With this code, if i search &quot;Chocolate&quot; in the search form, the product will be returned. But if i search &quot;confection&quot; : no results.
  <a href="https://i.stack.imgur.com/WQQYK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WQQYK.png" alt="Frontend search result" /></a></p>