Forums › Forums › Search & Filter Pro › WooCommerce 'All Caegories' Search
Tagged: search, Template, woocommerce
- This topic has 9 replies, 2 voices, and was last updated 10 years, 1 month ago by Anonymous.
-
Anonymous(Private) November 19, 2014 at 4:03 pm #7830
Hi,
I am trying to use this plugin to search against my WooCommerce product database.
If you head over to http://cu9088.hypedev.com/ you will see that the search bar is sitting nicely in front of the header image.
If you use this input and select a category (e.g. Bathroom Spot) and enter a term (e.g. Chrome), you will see that the resulting page shows the WooCommerce Products using the WooCommerce archive template.
However, if you go back and use the same search term, but this time choose ‘All Product Categories’ as the option from the select, you will notice that the results are displayed on the search.php template file provided by my theme.
How can I ensure that the WooCommerce template displays all the time?
Something I have noticed is that if I change the ‘post_types’ to ‘post_type’ in the results page url like so…
http://cu9088.hypedev.com/?s=Chrome&post_types=product
to
http://cu9088.hypedev.com/?s=Chrome&post_type=productI get the desired template page.
Is this a bug with the plugin, or is there something I am configuring incorrectly?
I have tested this with both the Pro and unpaid versions with no luck.
Matt
Ross Moderator(Private) November 19, 2014 at 4:34 pm #7835Hey Matt
You need to tick “use custom template” – and then specify the location of the woocommerce template file – this is so the plugin knows which template to use.
However, saying that, I had a look at the site, and it says you are using the free version of the plugin?
Pro version is very different to the free version – make sure you disable the free plugin first before trying to use 🙂
Thanks
Anonymous(Private) November 20, 2014 at 10:16 am #7899Hi Ross,
Thanks for your super quick response :).
I’ve have made the adjustments you mentioned (ignore the styling of the search form, I’ll sort that later) and although it is now using the correct template, it is not being recognised as a WooCommerce search.
If you run a search, leaving the text input blank and selecting ‘All Product Categories’, you will notice the results display. If you now append the url with the post type ‘&post_type=product’ it will show the same result on the template page, but with the filters etc.
http://cu9088.hypedev.com/?sfid=23752
http://cu9088.hypedev.com/?sfid=23752&post_type=productIs there anyway I can ensure the post_type=product is always in that url? I have tried using the ‘Set a Slug’ option, but upon saving my ‘&’ and ‘=’ are being stripped and the slug is becoming ‘post_typeproduct’
Thanks for your help.
Matt
Ross Moderator(Private) November 21, 2014 at 2:08 pm #7973Hey Matthew, surely you dont need that in the URL? With that in the URL, all it is doing is filtering your results by the post type “product” – this is something built in to wordpress already.
Why dont you, in S&F settings panel, choose only the post type “product” (the checkbox’s)? Does that now work as you would want?
Thanks
Anonymous(Private) November 21, 2014 at 2:52 pm #7987Hi Ross,
I have already selected the option to use the post type ‘product’ only. I think it perhaps has something to do with how the WooCommerce plugin recognises a product search. Maybe it relies upon the post_type=product variable being in the URL? I’m not sure though.
Is there anyway I can append &post_type=product to the url? I don’t mind editing the plugin to achieve this.
Thanks again for your help.
Matt
Anonymous(Private) November 24, 2014 at 1:38 pm #8086Hi Ross,
I have been able to solve this issue by editing the Search and Filter plugin (not the paid pro version).
I changed line 879 in search-filter.php from
$this->urlparams .= “post_types=”.$post_types;
to
$this->urlparams .= “post_type=”.$post_types;
Basically just removed the ‘s’.
I’m not yet sure how this would react if you now try to search multiple post types using the plugin, but it works perfectly for the WooCommerce ‘products’ post type search, now pulling in the layered navigation in the sidebar.
Thanks
Matt
Ross Moderator(Private) November 25, 2014 at 3:09 pm #8178Hey Matthew
Thanks for the info and how you managed to get it working… just to make sure I am following you properly and can help other users:
1) your results are displaying fine (style/layout), but WooCommerce does not recognise this as a product page?
2) adding the code you mentioned, allows other WooCommerce functionality to work properly on this page?Thanks!
Anonymous(Private) November 25, 2014 at 3:15 pm #8181Hi Ross,
Yes that is correct, although previously the template (style/layout) was incorrect when searching with the ‘All Products’ selection (it was using the default WordPress search page as opposed to the WooCommerce archive page).
Adding this code has ensured the correct template is always used for a WooCommerce search, and that the WooCommerce functionality (filters etc.) is displayed.
Thanks
Matt
Ross Moderator(Private) November 25, 2014 at 8:21 pm #8193Ok great thanks for the info Matthew.
I think potentially this could have been fixed by setting up the correct template to display the results?
I’ve just given some similar advice to another user:
1) Make sure
use custom template
is ticked
2) Make sure the woocommerce template files are copied in to your theme folder (http://docs.woothemes.com/document/template-structure/)
3) Set the custom template towoocommerce/archive-product.php
I only mention this because you will have problems upgrading this plugin and need to keep making edits to the core plugin files every update :/
If you find time to try that I’d be interested in the results.
Thanks again for your detailed info.
Anonymous(Private) November 26, 2014 at 9:21 am #8221Hi Ross,
I had actually given that a go previously. Setting the template solves the styling issue, but it doesn’t pull in the WooCommerce Layered Nav (product filters), because these only show on the WooCommerce Archive Page.
I believe that when the post_type=”product” is set, it somehow forces the loading of the search results to use the WooCommerce archive page, and that for whatever reason post_types is not recognised as a condition to also force this.
It’s ok, I’ll fork the plugin and monitor updates. The solution is relatively simple so it shouldn’t be too tough for me to recreate after updating in the future.
Thanks for all your help.
Matt
-
AuthorPosts