Include a segment label for the variation parent when segmenting a single product report by variations.

This commit is contained in:
Jeff Stieler 2019-08-19 10:47:09 -07:00
parent 150feee517
commit 8a19d586af
1 changed files with 9 additions and 0 deletions

View File

@ -378,6 +378,15 @@ class Segmenter {
$segments[] = $id;
$segment_labels[ $id ] = $segment->get_name();
}
// If no variations were specified, add a segment for the parent product (variation = 0).
// This is to catch simple products with prior sales converted into variable products.
// See: https://github.com/woocommerce/woocommerce-admin/issues/2719.
if ( empty( $this->query_args['variations'] ) ) {
$parent_object = wc_get_product( $this->query_args['product_includes'][0] );
$segments[] = 0;
$segment_labels[0] = $parent_object->get_name();
}
} elseif ( 'category' === $this->query_args['segmentby'] ) {
$args = array(
'taxonomy' => 'product_cat',