Created
June 25, 2016 14:13
-
-
Save cadros/8e409be574698ace3c685c570be40d59 to your computer and use it in GitHub Desktop.
Busting WooCommerce mini-cart output cache on dev site
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Add inline script to refresh the WooCommerce (widget) mini-cart output | |
* @see woocommerce\assets\js\frontend\cart-fragments.min.js | |
*/ | |
function bust_woo_minicart_cache() { | |
// if( get_theme_mod('tired_of_hard_caching') ) : | |
wp_add_inline_script('my_script_handle', "<script type='text/javascript'> window.sessionStorage.setItem('wc_fragments', null)</script>" ); | |
// endif | |
} | |
add_action( 'wp_enqueue_scripts', 'bust_woo_minicart_cache' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment