Merge pull request woocommerce/woocommerce-admin#1779 from woocommerce/fix/products-stats-segment-product-filter-cats

Fix/products stats segment product filter cats
This commit is contained in:
Paul Sealock 2019-03-14 08:20:02 +13:00 committed by GitHub
commit 8b3a437780
1 changed files with 9 additions and 1 deletions

View File

@ -311,11 +311,19 @@ class WC_Admin_Reports_Segmenting {
'limit' => -1,
);
// @todo: filter by categories if $this->query_args['categories'] is set.
if ( isset( $this->query_args['product_includes'] ) ) {
$args['include'] = $this->query_args['product_includes'];
}
if ( isset( $this->query_args['categories'] ) ) {
$categories = $this->query_args['categories'];
$args['category'] = array();
foreach ( $categories as $category_id ) {
$terms = get_term_by( 'id', $category_id, 'product_cat' );
$args['category'] = $terms->slug;
}
}
$segment_objects = wc_get_products( $args );
foreach ( $segment_objects as $segment ) {
$id = $segment->get_id();