janizde/WP-Opening-Hours

Adding page to export opening hours as json

Closed this issue · 1 comments

Hello, thank you for a great plugin!

I am interested in being able to read the opening hours via a json.
How would it best be implemented? I can try to do it myself if I get some hints.

Hi, you can have a look at the Set class: https://github.com/janizde/WP-Opening-Hours/blob/master/doc/developer-guide.md#sets

You can get the instance of a specific set, read the Periods, Holidays and IrregularOpenings and then create a JSON represenation (transform the data to associative arrays and then use the json_encode function to serialise it). You can also use the OverviewModel class to compress the opening hours for a specific week and then use its result.

Hope that helps, let me know if you have some more questions on this.