Skip to content

Commit

Permalink
give search related query string its own array key
Browse files Browse the repository at this point in the history
give search related query string its own array key for better access during woocommerce_get_filtered_term_product_counts_query
  • Loading branch information
twoelevenjay committed Jul 9, 2016
1 parent b94ff6b commit a9b2c7e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions includes/widgets/class-wc-widget-layered-nav.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,15 +368,15 @@ protected function get_filtered_term_product_counts( $term_ids, $taxonomy, $quer
AND terms.term_id IN (" . implode( ',', array_map( 'absint', $term_ids ) ) . ")
";
if ( is_search() ) {
$search_terms = $wp_query->query_vars['search_terms'];
$count = 0;
$query['where'] .= " AND (";
$search_terms = $wp_query->query_vars['search_terms'];
$count = 0;
$query['search'] = " AND (";
foreach ( $search_terms as $search_term ) {
$query['where'] .= $count > 0 ? " AND " : "";
$query['where'] .= "((wp_posts.post_title LIKE '%" . $search_term . "%') OR (wp_posts.post_excerpt LIKE '%" . $search_term . "%') OR (wp_posts.post_content LIKE '%" . $search_term . "%'))";
$query['search'] .= $count > 0 ? " AND " : "";
$query['search'] .= "((wp_posts.post_title LIKE '%" . $search_term . "%') OR (wp_posts.post_excerpt LIKE '%" . $search_term . "%') OR (wp_posts.post_content LIKE '%" . $search_term . "%'))";
$count++;
}
$query['where'] .= ")";
$query['search'] .= ")";
}
$query['group_by'] = "GROUP BY terms.term_id";
$query = apply_filters( 'woocommerce_get_filtered_term_product_counts_query', $query );
Expand Down

0 comments on commit a9b2c7e

Please sign in to comment.