Caching made the website display that it was closed even when its open.

We are using a Store Closing plugin that opens and closes the website and stops people from ordering while closed. While using caching it made the website display that it was closed even when its open.

At the moment, shop page is excluded from caching, is it possible to have cache enabled on shop page and at the same time fix the issue with the plugin?

  • James Morris

    Hello Keith

    After reviewing your chat transcript, it seems as though adding your store pages to the exclusion list has resolved the problem of the store appearing closed while it actually was not. Which, is the standard procedure for accommodating dynamic content such as you are using.

    At this time, Hummingbird's native support for cache triggers are limited to post/page publication, manual intervention and a define.

    The define I'm referring to is:
    define('DONOTCACHEPAGE', true);

    That define can be added to your page templates to prevent caching of pages that use that specific template only.

    To make this more dynamic I'm afraid would require custom coding based on the plugin you're using to change this define based on that plugin's triggers. In pseudocode (non-functioning example code) it would be something like:

    if ( store_is_active() === 'true' ) {
        define('DONOTCACHEPAGE', true);
    } else {
        define('DONOTCACHEPAGE', false);
    }

    I will go ahead and ping our SLS Team to see if they can offer some insights into this issue, but since this is a custom code integration with another product, this may take some time to look into and may fall outside the scope of support. However, perhaps the above will give you a starting point for your own research as well. You may also want to speak with the developers of the plugin you are using since this is really a matter of altering their display logic to work with any caching plugin.

    Best regards,

    James Morris

  • Konstantinos Xenos

    Hi Keith !

    After looking out at the plugins code we figured out that there was no 'easy' way of tapping in when the store changes state in open/close, as it reads the time constantly without using any transients to save the current state. Without a transient this results on always calling out code to run so it meant that you could either clear cache always ( pretty much like not using cache at all ) or just have an admin manually clearing it.

    But! You can paste the following code into your child themes functions.php and every time the store changes state from open to close, it will call out to Hummingbird to clear it's page cache and stay like that until the store changes state again, as we added a custom transient for that matter.

    [ What is a transient? Think of it like a memory inside WordPress that you can store some options and check/alter them that have a time-limit ]

    add_action( 'init', function() {
    	$hb_wsc_active_plan = get_site_option( 'storeclosing_activeplan' );
    
    	if ( false === $hb_wsc_active_plan || ! class_exists( 'WP_Hummingbird_Utils' ) ) {
    	 	return;
    	}
    
    	$store_status = $hb_wsc_active_plan['store_check'];
    	$status       = get_site_transient( 'check_store_status' );
    
    	if ( false === $status ) {
    	 	set_site_transient( 'check_store_status', $store_status, 0 );
    	} else {
    	 	if ( $store_status != $status ) {
    	 	 	set_site_transient( 'check_store_status', $store_status, 0 );
    	 	 	WP_Hummingbird_Utils::get_module( 'page_cache' )->clear_cache();
    	 	}
    	}
    } );

    I hope this helps!

    Best regards,
    Konstantinos

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.