Forums Forums Search & Filter Pro Search Results, Conditional Tags and Woocommerce

Viewing 4 posts - 1 through 4 (of 4 total)
  • Anonymous
    #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
    #18597

    Hey 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:

    http://www.designsandcode.com/wordpress-plugins/search-filter-pro/docs/display-results/with-a-shortcode/

    I’m sure there is something I’m missing but thought I’d suggest it.

    Thanks

    Anonymous
    #18832

    Perfect, 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
    #18907

    Just 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

Viewing 4 posts - 1 through 4 (of 4 total)