How to render an element with mutiple conditions time & date?

Guys, I am stuck and need some help with conditions.
I want to render an element based on weekdays and time, so the element should render:

  1. Mo - Thu - before 08:00 and after 17:00
  2. Fridays from 12:00 to 23:59
  3. Saturdays and Sundays

What I got:

  1. Mo - Thu - before 08:00 and after 17:00 - this translates to:
    Weekday >= Monday AND Weekday <= Thursday AND Time <= 08:00 AND Time >= 17:00

  2. Friday - after 12:00 and before 23:59
    Weekdays == Friday AND time >=12:00 AND time <=23:59

  3. Saturday and Sunday
    Weekdays <=Saturday AND weekdays <= Sunday

When implementing these conditions individually on ‘duplicated’ elements, they all work fine. However, as soon as I try to combine them on 1 element with OR they fail to work.

What am I doing wrong here? Any help is appreciated.

Hi @cmgramse,

I think you should use AND :slight_smile:

HI @MartinWB - so you mean I should use AND between the individual sets of conditions like so:

  1. Mo - Thu - before 08:00 and after 17:00 - this translates to:
    Weekday >= Monday AND Weekday <= Thursday AND Time <= 08:00 AND Time >= 17:00

AND

  1. Friday - after 12:00 and before 23:59
    Weekdays == Friday AND time >=12:00 AND time <=23:59

AND

  1. Saturday and Sunday
    Weekdays <=Saturday AND weekdays <= Sunday

–if that’s the case how am I going to do that…? I thought the OR in between sets was a given…

If you click on the + at the top where it says “Conditions” to add a new Condition you get “OR” but if you click on the “+” at the bottom of the existing condition then it adds the next as an “AND”.

Not very intuitive and would be much better if you could just click on the AND/OR to toggle it.

1 Like

Sorry for late reply… Yes, use AND as @alanj explained… It should work as you expect :slight_smile:

Hi @alanj and @MartinWB - thanks for replying! After fiddling around with the conditions I realized that my first approach above did not work. It is quite difficult to test.

a) One thing I found out was that for time conditions, you need to check that the WordPress instance is actually running on the correct timezone - in my case AMSTERDAM did not really work, I had to use UTC+1.

EDIT: Right now I am uncertain that the WP time-settings are recognised in Bricks. When I use the UTC time my conditions work as expected, as soon as I enter ‘local’ (server) time - things do not respond correctly…

b) I had problems in defining conditions-sets that use 2 ‘in-between’ expressions such as:
(day>=Mo. AND day<=Th.) AND (time<=08:00 AND time>=17:00)
This did not really work as expected. Instead I had to use the following:
(day>=Mo. AND day<=Th. AND time<=08:00) OR (day>=Mo. AND day<=Th. AND time>=17:00)

I have attached an image of the complete conditional expression that I am currently testing.

As to your replies: In my opinion, you can only add ‘AND’ in a conditon-set through the “+” at the bottom of an existing condition. In-between condition sets you can only add an ‘OR’.

Thanks for the help.

So I have done some further testing. I have adjusted the conditions to the following:

  1. Day>=Monday AND Day<=Thursday AND Time<=07:00 AND Time>=16:00
    OR
  2. Day==Friday AND Time<11:00
    OR
  3. Day == Saturday
    OR
  4. Day == Sunday

Following observations:
a) Local time does not seem to be considered by BRICKS conditions. I have to use UTC time, then the time conditions work as intended.

b) Combining condition-set (1) with condition-set (2) as shown above will cause the element to be rendered ALWAYS at time of (2), irrespective of the ‘DAY’ condition. To me this seems to be a BUG - but I would really like someone else to confirm this!