I am not an ACF expert at all. I am just learning it, too. There is some great support, in my experience, here but I suggest you try to explain what you have tried thus far.
One idea is to make open hours and day a repeater field? You could have a dropdown to select the day of the week, and a text box for open time and a text box for close time in 24 hour format, for example. You could also use a time picker to ‘from’ and ‘to’ instead of input boxes. This way you could have several entries for each day (eg. one entry: Monday 0900 1200, next entry: Monday 1300 1700).
Once you have above working, you would just grab the current time and day.
$day = date('w', $timestamp); // just one example
Above would return a number from 0 to 6. 0 is Sunday and 6 is Saturday.
Then you would loop the repeater field to find that day if it existed.
Then you would grab the time. Lots of ways to do that.
Then you would loop the repeater field to see if it falls between from/to.
If true, it is open and you just need to calculate the current time to the next close time and then maybe the next open time. If false, you would search for the next open day and time and calculate the time.
Maybe you could add another field to log national holidays or other closed days. It could be a date with a input field for comments. The first loop would test to see if today was a national holiday or a store closer and echo the comment field could mention the reason why the store was closed.
Just ideas. Hope this helps. Try to get the first step of capturing the day, from-time and to-time in a repeater field.
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users