Login

To vote or comment, enter your email and we'll send a magic link

1

Conditional Logic improvements

planned

I have the following suggestions for improvement of the Facetwp conditional logic add-on.

On a certain term archive page, I have set up some conditional action based on a chosen selection for a Type facet (based on post types). For example: if Facet Type is 'Accommodation' -> show several additional facets, to drill down in Accommodations. And else do the opposite.

This works of course, but it has the effect that on my Accommodations archive page, the same 'drill down' facets are not shown, because the whole Type facet is not active/present there, and the 'Else do the opposite' is the cause of this.

So what I would suggest is:

  • the condition that says IF Facet X is Y then A, should work like: IF Facet X EXISTS AND is Y then A. Or at least make it optional to add a condition that is actually exists.

  • The conditional 'Page URI' could help also in this case, but is unusable now, I have to enter a hard url. What I cannot say now, but would be very helpful: if page uri = taxonomy X, or = post_type_archive X. Or even more flexible, make a custom field where I can write WP conditional statements myself, selecting the exact archive pages this conditional ruleset or rule should apply to.

Basically, this Conditional Logic add-on is not usable in my case because I have different types or term- and post type archives with different facets. And the 'else do the opposite' now prevents facets from showing up, purely because the 'conditional facet' is present on some pages and not on others.

In one case I could solve it by making a 'counteract' ruleset with the page uri field set to NOT. But this does not work with taxonomy term archive pages for example.

One unpractical workaround I did not try would maybe be to use the Custom selector option and write some jquery that selects a sibling, thus not selecting it if the sibling is not there. But this is getting unnecessarily complicated, as I have many facets and this situation is there for a lot of conditions I would like to build.

3 weeks ago

Comments (4)

Right now the add-on only supports Conditions and Actions.

It sounds like you'd looking for something like Location Rules, where you can define whether the ruleset even runs on the given page...?

3 weeks ago

Yes if you put it that way. Separating location would be logical I guess. But now, the' page uri' field sort of does this too, right. But that is unworkable most of the time.

And the other thing is that 'else do the opposite' should check for if the facet exists at all. That would solve a lot of problems.

3 weeks ago

Right now, "Page URI" is a condition... the ruleset runs regardless of what's set. But I think Page URI should also be allowed to be a "pre-condition"... i.e. to determine whether the ruleset should even run in the first place.

Re: "do the opposite", could you elaborate? I feel like there'd be cases where certain things should happen if the value doesn't match OR the facet doesn't exist...

2 weeks ago

About 'Do the opposite':

Maybe best explained with an example:

I have a posttype Accommodations. On the Post type archive I have a facet Accommodation Type (from a custom taxonomy Accommodation Type). Eg. hotel,lodge,camping etc.

On another archive page, for example a term page for one of my Countries from a Countries taxonomy, I have a facet called Type (retrieving the different posttypes). One of the posttypes is Accommodations. Another would be Destinations. Etc.

Now, using Conditional Logic, I want this to happen on the Country page:

  • When a user selects Accommodations from the Type facet, then show the Accommodation Type facet, and Else Do the opposite (because I dont want the Accommodations Type facet to show when Accommodations is not selected in the Type facet. This all works fine. Except, on my Accommodations archive page, the Accommodation Type facets do not show up anymore because of the logic rules.

So, this happens because the same facets are used in different contexts and the logic is different for the contexts. That's why a condition where you can select a location (maybe with WP conditional tags) would be helpful here.

In the above example, it would also help if the logic would test for the Type facet to exist on the page at all, before applying the logic.

I mentioned the Pagi URI field because if this situation happens on a page that I can select with this field easily, as a workaround for above problems I can make a 'counteracting' ruleset that has the condition IF Page URI is not /xx, also show my facets. I actually have that applied currently for another situation. Not nice to look at but it works. However, the Page URI field is unusable when I have filters for example above each term archive page of a taxonomy, all with different slugs of course.

2 weeks ago