Home › Toolset Professional Support › [Resolved] Set up Product Archive with Filter
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Our next available supporter will start replying to tickets in about 0.84 hours from now. Thank you for your understanding.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | - |
- | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | - |
Supporter timezone: Asia/Kolkata (GMT+05:30)
Tagged: Toolset Blocks, Views, Views plugin, WordPress Archives
Related documentation:
This topic contains 27 replies, has 2 voices.
Last updated by jamesW-26 4 years, 5 months ago.
Assisted by: Minesh.
Tell us what you are trying to do?
Set up a product archive page that is already filtered by the product category that is selected (if any) and display further filter options in the left column.
Is there any documentation that you are following?
If I could find any on your site i would, but no.
Is there a similar example that we can see?
hidden link
What is the link to your site?
hidden link
Hello. Thank you for contacting the Toolset support.
I would like to know that are you using Toolset blocks to create your product archive or your are using legacy views?
Hi Minesh,
Legacy. I used WP > Toolset > Views and WP > Toolset > Layout to build it.
And just to be clear what the issues are ...
1. The products don't filter by category even though the URL is the actual category archive
2. The filters don't filter the products
Thanks
In general, you can not build custom search with taxonomy archive. You can only build the custom search with post type views and archive.
If you can share access details I would like to review how you setup the taxonomy archive, once I review it I will be able to guide you in the right direction.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
Thank you for sharing access details.
There still seems some misunderstanding. Let me clarify first because in ticket title you shared "Set up Product Archive with Filter" and the problem URL you shared is actually a taxonomy archive:
- hidden link
I checked with your site and I checked on left column of your layout you added a different view and on right side where it displays the results (output), you added a different view. Actually, you need to add the same view where on left column you should add only search form and on right column that displays the results you should add the search results.
So, please check the following details with clarification and once you clarify the things I will be able to guide you in the right direction.
1)
- If you want to build the product archive (that is custom post type archive for post type product), you can build the custom search and add as many filters to it like product category, custom field filters etc..etc.. this is perfectly possible.
2)
- if you want to build the product category archive (that is called taxonomy archive for product category), you can not filter product category archive with the same product category frontend filter because its not logical.
For example - lets consider the following structure:
- post 1(term A)
- post 2(term B)
As you can see post 1 is assigned to "term A" and post 2 is assigned to "term B".
Now, lets consider that you are on "term A" taxonomy archive page of your product category taxonomy, its not logical to display post 2 in archive page of "term A" as post 2 belongs to actually "term B" and it should be displayed on "term B" taxonomy archive page. This is a limitation of WordPress core.
So, here is my questions:
- Do you want to setup Product Archive or Product Categories archive?
- If you want to setup Product Categories archive - do you still want to add product categories frontend select dropdown filter using which you can change the product category and filter the result on product category archive?
In addition to that, FYI, Layouts plugin is in maintenance mode and we are not going to add any new features to it in future as we are moving to Toolset Blocks that will offer you the GUI way to build content templates, views and archives. If you still want to go with Layouts that is perfectly OK.
Can you please share your thoughts on above mentioned details and I would be happy to guide you in the right direction.
Hi Minesh,
Thanks for your last reply. I think I understand what you mean.
Forgive my incorrect referencing of what I am after. To me, a "product archive" is a list of products and a "category archive" is a list of categories. Let me try to answer your questions and explain what I need, based on what you said. I'll detail all of the things I need. I was just working on one of them to wrap my head around and understand how it works. But I might as well tell you all of the things I am trying to do, hopefully they are all possible.
I believe that I actually need 3 different "archives". All of them are related to WooCommerce Products and Categories/Sub-Categories.
1. List of sub-categories within a main category.
If you look at one of the top-level product categories on their current live site, you can see exactly what I mean: hidden link
There is a list of sub-categories that are under the main category. Note that no products are listed.
2. List of products within a sub-category.
(I think you are referring to this as a category archive??)
This is a list of products within any given product sub-category. It needs to have filtering options on the left. For example, 'Brand' and 'price range'.
It will also need to have certain filtering options that are sub-category specific. For example, in a sub-category of televisions, there would be a filter for the size of the screens, but this filter wouldn't show for other sub-categories. However, in another sub-category, for example DSLR Cameras, there might be a filter for color, which only shows on the DSLR Camera's sub-categories. No need to set these up yet, just need to know how to do it.
3. Search results page.
This will obviously be a list of products that fit the criteria of what someone typed into the search bar at the top of the page. It needs to have top-level category filter, as well as a sub-category filter based on which top-level category filter is selected. It also needs to have a Brand filter and a price range filter.
Hopefully that all makes sense and answers your questions. I apologise if not. By the way, I tried using a Layout as one of your videos said that was the way to do it. I had no idea the Layout facility is in maintenance mode. Happy to use blocks instead, I just want it to work so happy to use whatever tools you recommend to achieve it. Also, I am fairly sure I added the same view in left hand column and main colums, as per the instructions in the video (can't remember which one as I watched a lot of them). If you login and have a look, you will see.
Let me know if you need any more clarification on anything.
Thank you,
James
Ok - Thanks for the details and it seems that you need to go with Layouts as Blocks view do not support taxonomy type views yet.
To demonstrate how category -> Sub-Category -> Products will work I've setup a test site for you and setup a demo so that you can review it how it works.
You can access the test site:
URL: hidden link
user: demo
pwd: Admin@999
With the following link You can see all the Top level category is displayed:
=> hidden link
- When you click on any of top level category displayed on the above link, it will display the associated subcategory
- For now only "Boots" and "Trainer" category has subcategories
- once you click on "Trainer" category, it will display the associated subcategories to Trainer as follows:
=> hidden link
- Now, when you click on any subcatgory - it will redirect you on the associated archive page.
=> hidden link
- You can add products as currently no products are added to any of subcategories.
This is the taxonomy view that is used to display category -> sub-category -> product (archive)
=> hidden link
I've added the following code to the "Custom Code" section of Toolset
=> hidden link
add_filter( 'wpv_filter_taxonomy_query', 'func_filter_and_display_related_subcategories', 99, 4 ); function func_filter_and_display_related_subcategories($tax_query_settings, $view_settings, $view_id) { if($view_id == 1746){ (!isset($_GET['taxonomy_id']))? $tax_query_settings['child_of']=0:$tax_query_settings['child_of'] = $_GET['taxonomy_id']; } return $tax_query_settings; }
Where:
- The above filter hook is used to display top level category and subcategory based on URL param taxonomy_id.
add_filter( 'wpv_filter_taxonomy_post_query', 'prefix_check_items', 20, 4 ); function prefix_check_items( $items, $tax_query_settings, $view_settings, $view_id ) { if($view_id == 1746){ foreach( $items as $item ) { $children = get_term_children( $item->term_id, 'product_cat'); if(count($children)==0){ $item->name = '<a href="'.get_term_link($item->term_id).'">'.$item->name.'</a>'; }else{ $item->name = '<a href="?taxonomy_id='.$item->term_id.'" target="_self" >'.$item->name.'</a>'; } } } return $items; }
Where:
- The above filter hook s used to identify, if the item as child then display the subcategory then display the subcategory link otherwise display the product archive link.
Please let me know if you need further help to understand the structure.
Hi Minesh,
Thanks for showing me that. There's a few issues ...
1. How do you apply that to the built-in category archive within WordPress? You have done this using a WordPress Page, not the actual category archive. I need it to work on the category archive. I apologise if I didn't make this more clear before.
2. The URL's have parameters in them. e.g. "?taxonomy_id=32". Can it be done with pretty URL's? This is extremely important for SEO purposes.
3. The example you set up doesn't display products.
Please note that I am almost out of time with this project. I need to present this as a working model to my client tomorrow, otherwise I am at risk of losing the job. I started this thread 6 days ago and we have had much communication, however it feels like I am no closer to getting an answer on how to set this up.
Thank you for your help so far, I appreciate it. I hope we can get it sorted out by tomorrow.
James
Can we please organise a phone call or at least a chat window? This current method is averaging 1 response per day which is not acceptable. I feel that we could get it sorted very quickly if you can be available to do a chat session. Surely, if I paid $300 for this software you would make that available?
Ok - As you clarify that you want to go with only Taxonomy (Product Category) archive where you want to display the sub-categories and when you select any specific sub-category, it should display the associated products.
I have a workaround to offer you and as I got the news that you are available for the call and I am ready to show you the workaround as you requested for the chat.
I can write you details here but as you requested the quick assistance, You can send me the link to join the call. You can setup a zoom or google meet and send the invitation link to my email: minesh.s@onthegosystesm.com.
Thanks Minesh, I have emailed you the Google Meet link.
Thanks - Please let me know if you will require further assistance.
Hi Minseh,
I have everything that we worked on coming together. There are a few small issues which I will ask you about, but first, there is 1 final primary issue. The list of sub-categories. So this is for viewing a top-level category and seeing the sub-categories. Here is how it currently looks hidden link as it seems to be using the native WP template for it. Can you please set it up so that it uses a Toolset so that I can style the page?
Thanks,
James
I am not sure why the top level term is enforced to use the native WP template or Woocomerce rather the WP taxonomy archive we created as that is not the case with my test site.
Please make sure to update ALL plugins to latest version from your plugins page.
It seems to me that there is conflict between any of third-party plugins you are using or theme but to ensure that you will require to run a test with minimum installation where only Toolset plugins is active with your site.
In order to minimise the cause of the issue:
Could you please try to resolve your issue by deactivating all third-party plugins as well as switch to the default theme (2020) to check for any possible conflicts with any of the plugins or themes?
- Do you see any difference? if no:
I will require duplicator copy of your site.
I have updated all plugin (except for ones that require license - disabled those), no change.
I switched to 2020 theme, and reset the Toolset templates on Woocommerce Views page, no change.
Please note that one of the plugins removed the "/product-category/" from the URL, so now with that plugin disabled the URL for top-level categories are like this: hidden link
Also, I don't know when, but part of that conditional code that you put in is not there anymore. I certainly didn't remove it. Only the first part "[wpv-conditional if="( woo_has_product_subcategory() eq '0' )"]" is in there. Not sure if that is part of the problem.
With Duplicator, the site is 1GB (ish) in size and I have tried to create a package and it fails. I'm not sure why you need to have a copy of it when you have full access to it, including cPanel access (see above).