I have a site that uses a shopping cart plugin (Shopp), a plugin I wrote, and W3 Total Cache.
In my plugin, I’d like to make sure that W3 Total Cache does not serve any cached pages if the user has any items in their cart, however, I can’t seem to find the proper hook to define the constants that will disable W3 Total Cache caching. This is what I have at the very top of my plugin file (the shopp_init function runs during wordpress init
):
// do not cache anything if items are in cart
add_action('shopp_init', function(){
if (shopp_cart_items_count() > 0)
{
define('DONOTCACHEDB', true);
define('DONOTCACHEPAGE', true);
define('DONOTCACHEOBJECT', true);
}
});
It seems like if the DONOTCACHEPAGE
constant is detected once for a page, it won’t check for it again. So if I have any items in my cart at any point, it’ll never cache anything. Likewise, if my cart is empty once, it’ll always allow all pages to be cached.
How can I dynamically disable w3 total cache?
U could try using this type function:
Found it on this website
U’ll have to modify the nandlers to your needs, i found the W3TC handlers to be: