Hi Dima.
Thank you so much for your help and your explanation.
After what you wrote I started thinking, I disabled all plugins and then came to checking my customizations in functions.php in child theme. And I found it. It’s all caused by this piece of code: (After removing all is fine)
/*Exclude categories with no visible products from category widget*/
function kfg_exclude_categories_from_widget( $category_list_args ) {
$args = array(
'hide_empty' => false,
'hierarchical' => true,
);
$product_categories = get_terms( 'product_cat', $args );
$exclude = array();
foreach ( $product_categories as $category ) {
$posts = get_posts( array( 'post_type' => 'product', 'posts_per_page' => -1, 'product_cat' => $category->slug, 'fields' => 'ids' ) );
$show_category = false;
foreach ( $posts as $post ) {
$product = new wC_Product( $post );
$visible_product = $product->is_in_stock();
if ( true === $visible_product ) {
$show_category = true;
break;
}
}
if ( false === $show_category ) {
$exclude[] = $category->term_id;
}
}
if ( ! empty( $exclude ) ) {
$category_list_args['exclude'] = implode( ',', $exclude );
unset( $category_list_args['include'] );
}
return $category_list_args;
}
add_filter( 'woocommerce_product_categories_widget_args', 'kfg_exclude_categories_from_widget', 10, 1 );
Don’t you know how to edit this code, so that I could still use it an and also Ajax filter would work normally.? Thanks.
Radan