Nevermind, I’ve solved the visualisation condition by adding a custom keyword for a check on subcategories.
I write here the solution in case someone else would need it:
add_filter( 'eleconditions_vars', 'new_keywords');
function new_keywords( $custom_vars ) {
global $woocommerce;
if ( is_product_category() ) {
$term = get_queried_object();
$has_subcat = get_terms( $term->taxonomy, array(
'parent' => $term->term_id,
'hide_empty' => false,
'field' => count
) );
$custom_vars['has_subcat'] = ($has_subcat) ? true : false;
return $custom_vars;
}
}
I’ve added to the archive template two widgets: one for products archive and one for product categories, and I’ve put the condition on each one like this:
has_subcat !== true
(for products widget)
has_subcat === true
(for categories widget)
But now I have the problem to modify the Elementor query to show the subcategories for the current category and not always Top Level, but this is not something related to Elementor Element Condition…
I’ll update the post if I’ll find out, so the solution will be complete.