Skip Navigation

[Resolved] Custom Search Reset to reset to the shop page root and not to product category

This support ticket is created 3 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

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.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9: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: Africa/Casablanca (GMT+01:00)

This topic contains 6 replies, has 2 voices.

Last updated by Jamal 3 years, 6 months ago.

Assisted by: Jamal.

Author
Posts
#2124179

Tell us what you are trying to do?
I want the Custom Search Reset to make a full reset also when the search on the shop page is opened as a product category URL from the home page or the menu and not directly from the shop page search.

Is there any documentation that you are following?
no

Is there a similar example that we can see?
Screencast: hidden link

What is the link to your site?
hidden link

#2124363

Hello and thank you for contacting Toolset support.

If I understood well, you want the reset button on the category archive to reset the category dropdown and display all the categories instead of one, right?

That's not possible. Because a category filter cannot be used inside a category archive. If it is used, it will always display the selected category only.

I'll suggest one of the following:
- Either remove the category filter from the category archive.
- Or, ad some custom Javascript code that will redirect to the shop page when the reset button is clicked.

Let me know if you need help with either of them.

#2124421

Thank you, Jamal, since the Product Category filter is essential, the second option seems best in my case (- Or, ad some custom Javascript code that will redirect to the shop page when the reset button is clicked.).

I'm not good with Java, and appreciate your help with that.

#2124447

Add the following code to the archive's Javascript section and it should redirect to the shop page when the reset is clicked on a category archive page:

jQuery(function($){
    if ( /https:\/\/aroga.eu\/product-category\//.test(window.location.href) ) {
        $('.js-wpv-reset-trigger').on('click',function(ev){
            ev.preventDefault();
            ev.stopPropagation();
            window.location.assign('<em><u>hidden link</u></em>');
        });
    }
})

If that does not help, or you have any doubts on how to implement it, allow me temporary access to your website as an administrator and I'll help with it. Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **

#2125067

Apparently, the Javascript code was stripped by the archive template and caused errors. I updated the code a bit to make it work. The current code is:

jQuery(function($){
    if ( /product-category/.test(window.location.href) ) {
        $('.js-wpv-reset-trigger').on('click',function(ev){
            ev.preventDefault();
            ev.stopPropagation();
            window.location.assign('<em><u>hidden link</u></em>');
        });
    }
});

Please check if that achieves what would you expect, or if there is something I have missed.

#2126015

My issue is resolved now. Thank you, Jamal! You helped a lot! I'm promoting this search option as unique for my niche and, therefore, this was very important for my business.
Cheers,
Göran

#2126451

Thank you Göran for your feedback. I am glad I could help.

All the best,
Jamal