reports for subcats. Closes #1924.
This commit is contained in:
parent
5a7bfe980a
commit
86adc50964
|
@ -1918,7 +1918,7 @@ function woocommerce_category_sales() {
|
||||||
$current_year = isset( $_POST['show_year'] ) ? $_POST['show_year'] : date( 'Y', current_time( 'timestamp' ) );
|
$current_year = isset( $_POST['show_year'] ) ? $_POST['show_year'] : date( 'Y', current_time( 'timestamp' ) );
|
||||||
$start_date = strtotime( $current_year . '0101' );
|
$start_date = strtotime( $current_year . '0101' );
|
||||||
|
|
||||||
$categories = get_terms( 'product_cat', array( 'parent' => 0 ) );
|
$categories = get_terms( 'product_cat', array( 'orderby' => 'name' ) );
|
||||||
?>
|
?>
|
||||||
<form method="post" action="" class="report_filters">
|
<form method="post" action="" class="report_filters">
|
||||||
<p>
|
<p>
|
||||||
|
@ -1932,14 +1932,16 @@ function woocommerce_category_sales() {
|
||||||
|
|
||||||
<select multiple="multiple" class="chosen_select" id="show_categories" name="show_categories[]" style="width: 300px;">
|
<select multiple="multiple" class="chosen_select" id="show_categories" name="show_categories[]" style="width: 300px;">
|
||||||
<?php
|
<?php
|
||||||
foreach ( $categories as $category ) {
|
$r = array();
|
||||||
if ( $category->parent > 0 )
|
$r['pad_counts'] = 1;
|
||||||
$prepend = '— ';
|
$r['hierarchal'] = 1;
|
||||||
else
|
$r['hide_empty'] = 1;
|
||||||
$prepend = '';
|
$r['value'] = 'id';
|
||||||
|
$r['selected'] = isset( $_POST['show_categories'] ) ? $_POST['show_categories'] : '';
|
||||||
|
|
||||||
echo '<option value="' . $category->term_id . '" ' . selected( ! empty( $_POST['show_categories'] ) && in_array( $category->term_id, $_POST['show_categories'] ), true ) . '>' . $prepend . $category->name . '</option>';
|
include_once( $woocommerce->plugin_path() . '/classes/walkers/class-product-cat-dropdown-walker.php' );
|
||||||
}
|
|
||||||
|
echo woocommerce_walk_category_dropdown_tree( $categories, 0, $r );
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
|
@ -29,16 +29,19 @@ class WC_Product_Cat_Dropdown_Walker extends Walker {
|
||||||
$pad = str_repeat(' ', $depth * 3);
|
$pad = str_repeat(' ', $depth * 3);
|
||||||
|
|
||||||
$cat_name = apply_filters( 'list_product_cats', $cat->name, $cat );
|
$cat_name = apply_filters( 'list_product_cats', $cat->name, $cat );
|
||||||
$output .= "\t<option class=\"level-$depth\" value=\"" . $cat->slug . "\"";
|
|
||||||
|
|
||||||
if ( $cat->slug == $args['selected'] )
|
$value = isset( $args['value'] ) && $args['value'] == 'id' ? $cat->term_id : $cat->slug;
|
||||||
|
|
||||||
|
$output .= "\t<option class=\"level-$depth\" value=\"" . $value . "\"";
|
||||||
|
|
||||||
|
if ( $value == $args['selected'] || ( is_array( $args['selected'] ) && in_array( $value, $args['selected'] ) ) )
|
||||||
$output .= ' selected="selected"';
|
$output .= ' selected="selected"';
|
||||||
|
|
||||||
$output .= '>';
|
$output .= '>';
|
||||||
|
|
||||||
$output .= $pad . __( $cat_name, 'woocommerce' );
|
$output .= $pad . __( $cat_name, 'woocommerce' );
|
||||||
|
|
||||||
if ( $args['show_count'] )
|
if ( ! empty( $args['show_count'] ) )
|
||||||
$output .= ' (' . $cat->count . ')';
|
$output .= ' (' . $cat->count . ')';
|
||||||
|
|
||||||
$output .= "</option>\n";
|
$output .= "</option>\n";
|
||||||
|
|
Loading…
Reference in New Issue