But down there is product categories and these names are not updated - this is what you mean when you say "Remember, this solution does not support AJAX updates."
Right, in the View settings you must not choose AJAX search updates. You must add a submit button to the search form, then click submit in the search form to update the results. After you submit the search form, the page will reload and the Product Category counts will update to reflect the new search criteria.
I have finished working now and all these steps are fulfilled.
You skipped ahead a bit, but that's okay 🙂
Save the code from your Product View's loop in another Content Template as a backup. Right now, the View should display a list of Product IDs only. Copy and paste the code exactly from step 3. We must create a list of Product IDs first, then we will create another View that displays the Product information later. The Product IDs list is used in the next step to help generate the nested taxonomy term Views.
6. Copy this code and paste it in your child theme's functions.php file, or create a new code snippet in Toolset > Settings > Custom code:
function ts_get_brand_ids_for_posts_func($atts) {
$view_id = 12345;
$tax = "brand";
$filtered_posts = get_view_query_results( $view_id, null, null, null );
$post_ids = wp_list_pluck( $filtered_posts, 'ID');
$terms = wp_get_object_terms( $post_ids, $tax, array( 'fields' => 'ids' ) );
return $terms ? implode( ',', $terms ) : '';
}
add_shortcode("ts_get_brand_ids_for_posts", "ts_get_brand_ids_for_posts_func");
function ts_get_pcat_ids_for_posts_func($atts) {
$view_id = 12345;
$tax = "product_cat";
$filtered_posts = get_view_query_results( $view_id, null, null, null );
$post_ids = wp_list_pluck( $filtered_posts, 'ID');
$terms = wp_get_object_terms( $post_ids, $tax, array( 'fields' => 'ids' ) );
return $terms ? implode( ',', $terms ) : '';
}
add_shortcode("ts_get_pcat_ids_for_posts", "ts_get_pcat_ids_for_posts_func");
There are two places where you see the number 12345. Replace those numbers with the ID of the View of Product IDs. If your custom taxonomy slug is not "brand", then you should replace the slug in this line:
Change brand to match your custom taxonomy slug.
7. Now place these shortcodes on the basseinid-ja-niisked-ruumid page, somewhere outside the View, as a test:
Brand IDs: [ts_get_brand_ids_for_posts]<br />
Product Category IDs: [ts_get_pcat_ids_for_posts]<br />
8. Go to Toolset > Settings > Front-end Content and enter ts_get_brand_ids_for_posts and ts_get_pcat_ids_for_posts in the section "Third party shortcode arguments".