Forums › Forums › Search & Filter Pro › Search Results, Conditional Tags and Woocommerce
- This topic has 3 replies, 2 voices, and was last updated 9 years, 5 months ago by Ross.
-
Anonymous(Private) May 29, 2015 at 6:38 pm #18523
Hi there,
In Woocommerce, I’m using a code snippet to change the columns from 4 (standard) to 3 products per column. Works fine. The only page I want 4 products per column is the page that I’m using the search and filter shortcodes.
I have a conditional tag in my functions.php file that works perfectly until you select a search filter on the one page I want 4 products per column to display.
Code can be seen here: http://pastebin.com/6GgQmY2Q
The page I’m talking about is http://athenasarmory.com/search-by-gun-model/ . 4 products per column works until you select a model in the drop down.
Somehow , the results script controlled by the search and filter plugin ignores my conditional tag in the functions.php file after a search filter is selected. I’ve tried conditional tags for is_page_template , is_page(ID) etc…and they all work until an option is selected from that drop down and the results get processed. (or you select page 2, 3 etc)
Hopefully this is making sense 🙂 . Do you know of a conditional tag that I could use in my functions.php file that will remain TRUE even after the results are loaded?
As I’m typing this, I just realized I could probably change the script in functions.php to say “If page is woocommerce archive/category/etc, use 3 columns….if anything else, use standard 4 columns…” This wouldn’t be ideal but I guess it’s a solution if we can’t come up with a conditional tag the other way around that will work.
Ross Moderator(Private) June 1, 2015 at 11:45 am #18597Hey Brian
The conditional test for a S&F results page is something like:
global $sf_form_data; if ($sf_form_data->is_valid_form()) { //do stuff }
This might help – but I’m thinking – if you are displaying your results using a shortcode, why not just customise:
I’m sure there is something I’m missing but thought I’d suggest it.
Thanks
Anonymous(Private) June 3, 2015 at 5:46 pm #18832Perfect, thanks Ross! The conditional test worked perfectly.
I am using a custom template and shortcode to display the results, but because of the global override I’m using for Woocommerce to display rows of 3 for everything else instead of 4, the only way to get the search and filter results to ignore that override seems to be using a conditional test.
Cheers!
Ross Moderator(Private) June 4, 2015 at 1:06 pm #18907Just to let you know this will be changing in v2.0 – haven’t decided on the exact name yet but more likely it will be something like:
$searchandfilter->valid_form()
Just a heads up anyway 🙂
Thanks
-
AuthorPosts