Forums › Forums › Search & Filter Pro › JS to not show products on load
- This topic has 10 replies, 2 voices, and was last updated 4 years, 6 months ago by Trevor.
-
Anonymous(Private) May 4, 2020 at 10:12 am #242455
I have the S&F filter within the description of a woo category page, using it as a filter “builder” to show a certain selection of products based on the options selected.
naturally, the category shows all products within this category on load. I would like these not to be shown until the filter form is submitted. I could of course just hide the entire .products container with css, and then show it on submit of form, but this still means that the initial query is loaded in the background to retrieve all products.
is there a way?
Trevor(Private) May 4, 2020 at 3:18 pm #242521I am assuming that you are using the WooCommerce method? You could edit the PHP template being used and add some logic to test if a filter has yet been applied, like this (change the ID to match the form you are using):
global $searchandfilter; $sf_current_query = $searchandfilter->get(1234)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { echo '<div>Nothing to see here folks!</div>'; } else { // the current products output code here }
Anonymous(Private) May 4, 2020 at 4:45 pm #242566Thanks Trevor, I understand the logic here, but it doesnt appear to be working – potentially because I am using the AJAX to return the results, rather than a page refresh.
essetnially by wrapping the default category loop code with your conditional logic, it always says “nothing to see here folks”.
any clues?
-
AuthorPosts