• Resolved Sivustonikkari

    (@risalmin)


    The linked site is a restaurant, that has a pick up service made with Woocommerce. There is a PHP function that should run every time the page is loaded and check today’s opening hours and based on that open the pick up ordering if the restaurant is open and close the shop, if the restaurant is closed. There is a setting for opening and closing hours for each day of the week and it might change sometimes.

    It seems that I cannot make the page cacheable at all, since this function will never be on time, but an earlier version of the front page is offered and based on the time it was cached the shop is closed or open incorrectly…

    Is there anything I can do to speed up the front page, while still enabling the closing and opening based on the exact time.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support qtwrk

    (@qtwrk)

    Hi,

    is this open/close hour fixed ? or it always changing ?

    Best regards,

    Thread Starter Sivustonikkari

    (@risalmin)

    It is not fixed, it changes per season and they might be adjusted from time to time. There is an admin setting where I read the times. There would probably be a two to three hour time window at closing and opening where theses times are set. e.g. 10-12 and 21-23

    Plugin Support qtwrk

    (@qtwrk)

    Hi,

    for such case I can only think to set up a cron job to purge cache on homepage , and triggers it on the destinated time set by that open/close hour plugin.

    if it only shows up on front page, then you can try a hook like this

    do_action( 'litespeed_purge_url', '/' );

    to purge that URL

    but this may reuqire you to contact the open/close plugin author to help to add this cron accordingly.

    Best regards,

    Thread Starter Sivustonikkari

    (@risalmin)

    I am the author of the plugin so we are in luck there ??

    But how can I measure that that action fires, when the time checking does not work? Oh! You mean with a cron job? I’ll try that!

    Also, since REST calls are not cached, maybe I could use javascript to do the check…

    Plugin Support qtwrk

    (@qtwrk)

    Hi,

    yeah , cool

    well , I was thinking something when you change the timing , add a cron job to the list , let’s say , your time is changed at 09:00 , then add a cron to fire the purge through API for open , and another time at 19:00 , then another cron there to purge cache

    hmmmm , JS might be another way , but it may not be in real time as it is , as it requires a real user to trigger it?

    while with cron , you can just do system cron set on time which it never misses : )

    Best regards,

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Problem with timed opening hours’ is closed to new replies.