В отдельный файл сложите поправленный класс
if ( !class_exists( 'WPP_WC_Product_Cat_List_Walker_With_Thumb' ) ) :
class WPP_WC_Product_Cat_List_Walker_With_Thumb extends Walker {
public $tree_type = 'product_cat';
public $db_fields = array(
'parent' => 'parent',
'id' => 'term_id',
'slug' => 'slug',
);
public function start_lvl(&$output, $depth = 0, $args = array()) {
if ( 'list' != $args[ 'style' ] )
return;
$indent = str_repeat( "\t", $depth );
$output .= "$indent<ul class='children'>\n";
}
public function end_lvl(&$output, $depth = 0, $args = array()) {
if ( 'list' != $args[ 'style' ] )
return;
$indent = str_repeat( "\t", $depth );
$output .= "$indent</ul>\n";
}
public function start_el(&$output, $cat, $depth = 0, $args = array(), $current_object_id = 0) {
$output .= '<li class="cat-item cat-item-' . $cat->term_id;
if ( $args[ 'current_category' ] == $cat->term_id ) {
$output .= ' current-cat';
}
if ( $args[ 'has_children' ] && $args[ 'hierarchical' ] ) {
$output .= ' cat-parent';
}
if ( $args[ 'current_category_ancestors' ] && $args[ 'current_category' ] && in_array( $cat->term_id, $args[ 'current_category_ancestors' ] ) ) {
$output .= ' current-cat-parent';
}
$thumbnail_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true );
$img_url= wp_get_attachment_url( $thumbnail_id );
$image = ! empty($img_url) ? '<img class="wpp-term-thumb" src="' . $img_url . '" alt="" />' : '';
$output .= '"><a href="' . get_term_link( (int) $cat->term_id, $this->tree_type ) . '">' . $image . _x( $cat->name, 'product category name', 'woocommerce' ) . '</a>';
if ( $args[ 'show_count' ] ) {
$output .= ' <span class="count">(' . $cat->count . ')</span>';
}
}
public function end_el(&$output, $cat, $depth = 0, $args = array()) {
$output .= "</li>\n";
}
public function display_element($element, &$children_elements, $max_depth, $depth = 0, $args, &$output) {
if ( !$element || ( 0 === $element->count && !empty( $args[ 0 ][ 'hide_empty' ] ) ) ) {
return;
}
parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
}
}
endif;
В functions.php или где то еще, делаем так
function wpp_change_widget_product_categories_walker($array) {
require_once 'Путь_к_файлу_с_добаленным_классом';
$array[ 'walker' ] = new WPP_WC_Product_Cat_List_Walker_With_Thumb;
return $array;
}
add_filter('woocommerce_product_categories_widget_args','wpp_change_widget_product_categories_walker');