Help with query conditions for search page and sub categories

I’m adding addtional sub categories to my products and can’t quite seem to figure out the conditional logic in the query.

I basically want to view all products. and then if I filted the primary category it should show all in that category, and then once I pick the secondary category it should filter and show all. I can get this to all work properly. its just that when I add the next category I can’t get it to filter correctly. I’m confused on the logic here. Here is a video of the page with the first two categories working as it should.

And here is the conditions from the query statement

So that all works for two categories but once I try to add the third and eventually 4th sub categories, I’m lost on the logic. Any advice? I’d post some of my other attempts at the conditions but I just can’t seem to get it worked out. I must be missing something here that is simple or I need to nest if statements or something?

Seems you’re doing great, can you post a screenshot of your further attempts?

No nesting, just repeat what you’ve done for subcatfilter

Seems like this should work, but it doesn’t show until I put all the criteria in. It should show the unfiltered results until they get filtered.

You forgot this:

Yeah I did. But it still doesn’t work. I’ve tried it both ways.

I want a screenshot of your browser’s developer tools, the network tab, both the Request and Response of the relevant server connect call

I’m guessing the condition $_GET.subcatfilter and etc is still being evaluated to true even on an empty string (white-space?)

That actually might make sense, since the drop down is being populated from a DB query. I’ll look at that a little closer and see what I can find out. I’m on another job site today, so I’ll look at it first thing tomorrow and report back.

ok @apple you were on to the right idea. What I thought was an empty value in the first choice was not, on subcat2. I troubleshot by putting in a static value for the first choice so that I knew it would have an empty value and all works as it should! So just have to edit the value in the database to reflect what I need and I should all be good to go!

Thanks for your help. I knew it had to be something simple that I was missing but sometimes you try so many things you kind of hit the wall.

have a great week

1 Like