Skip to content

Instantly share code, notes, and snippets.

@cadros
Created June 25, 2016 14:13
Show Gist options
  • Save cadros/8e409be574698ace3c685c570be40d59 to your computer and use it in GitHub Desktop.
Save cadros/8e409be574698ace3c685c570be40d59 to your computer and use it in GitHub Desktop.
Busting WooCommerce mini-cart output cache on dev site
/**
* 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