I am trying to create an “opening hours” reusable block that I can use on a number of pages.
In ACF I have a field group with this setup
Monday Open: TRUE/FALSE
Monday Opening time: Time picker
Monday Closing time: Time picker
I currently have a headline block getting the data for the opening and closing times (so 2 headlines blocks and the second one has a prefix of " - ". What I would like to do if the shop is closed is display a headline with “closed” instead of the 2 headlines displaying the time.
I have the above in a row so I can duplicate it for each day.
Can someone help me workout how to display the closed if the open boolean is false?
I would suggest looking at Conditional Blocks - https://conditionalblocks.com/. It is fantastic plugin with good support. I use it on most projects.
Is there no other alternative?
I really don’t want another plugin at $50 a year
The Block Visibility plugin has ACF integration in the free version. You would need to setup multiple Headlines for each day and set them to show or hide based on the true/false.
If you’re using an ACF True/False field you would use field value is equal to 1 (true) or 0 (false).
For a site I did something similar on I ended up simplifying it because there were too many fields and blocks and conditional options! I just created 1 field for each day and the client can either enter text e.g. “Closed” or the opening and closing time together e.g. “9:00am – 5:00pm”. Each day is always shown, so I didn’t need to hide anything. It was a lot easier for me and there are less fields for the client to deal with in the editor. Win win!