Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Commit

Permalink
use category lookup id instead of term taxonomy id (#3027)
Browse files Browse the repository at this point in the history
  • Loading branch information
rrennick authored and psealock committed Oct 10, 2019
1 parent eb5a2c7 commit 2ba8d76
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/API/Reports/Products/Stats/Segmenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ protected function get_product_related_intervals_segments( $segmenting_selection
$orig_offset = intval( $limit_parts[1] );
$orig_rowcount = intval( $limit_parts[2] );
$segmenting_limit = $wpdb->prepare( 'LIMIT %d, %d', $orig_offset * $segment_count, $orig_rowcount * $segment_count );

// Can't get all the numbers from one query, so split it into one query for product-level numbers and one for order-level numbers (which first need to have orders uniqued).
// Product-level numbers.
$segments_products = $wpdb->get_results(
Expand Down Expand Up @@ -191,8 +191,8 @@ protected function get_segments( $type, $query_params, $table_name ) {

// Restrict our search space for category comparisons.
if ( isset( $this->query_args['categories'] ) ) {
$category_ids = implode( ',', $this->get_all_segments() );
$segmenting_where .= " AND wp_term_taxonomy.term_taxonomy_id IN ( $category_ids )";
$category_ids = implode( ',', $this->get_all_segments() );
$segmenting_where .= " AND {$wpdb->wc_category_lookup}.category_id IN ( $category_ids )";
}

$segments = $this->get_product_related_segments( $type, $segmenting_selections, $segmenting_from, $segmenting_where, $segmenting_groupby, $segmenting_dimension_name, $table_name, $query_params, $unique_orders_table );
Expand Down

0 comments on commit 2ba8d76

Please sign in to comment.