diff --git a/includes/walkers/class-product-cat-list-walker.php b/includes/walkers/class-product-cat-list-walker.php index 61e0d282679..f4b0ce84bf6 100644 --- a/includes/walkers/class-product-cat-list-walker.php +++ b/includes/walkers/class-product-cat-list-walker.php @@ -92,7 +92,7 @@ class WC_Product_Cat_List_Walker extends Walker { $output .= ' current-cat'; } - if ( $args['has_children'] && $args['hierarchical'] ) { + if ( $args['has_children'] && $args['hierarchical'] && ( empty( $args['max_depth'] ) || $args['max_depth'] > $depth + 1 ) ) { $output .= ' cat-parent'; } diff --git a/includes/widgets/class-wc-widget-product-categories.php b/includes/widgets/class-wc-widget-product-categories.php index 3d75219889d..15057317f22 100644 --- a/includes/widgets/class-wc-widget-product-categories.php +++ b/includes/widgets/class-wc-widget-product-categories.php @@ -246,6 +246,7 @@ class WC_Widget_Product_Categories extends WC_Widget { $list_args['show_option_none'] = __( 'No product categories exist.', 'woocommerce' ); $list_args['current_category'] = ( $this->current_cat ) ? $this->current_cat->term_id : ''; $list_args['current_category_ancestors'] = $this->cat_ancestors; + $list_args['max_depth'] = $max_depth; echo '