Skip to content

Instantly share code, notes, and snippets.

Last active April 18, 2017 08:53
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save daigo75/647dfb971c3bac3375b1 to your computer and use it in GitHub Desktop.
WooCommerce 2.4 – Price cache workaround - Disable cache
// This code is no longer required as of WooCommerce 2.5
* Disables the product price cache. This function looks for the cache key
* that is about to be retrieved by WooCommerce, and deletes the cached data
* associated to it.
* This function can have an impact on WooCommerce's performance, and it
* should not be used unless necessary.
* @param array cache_key_args The arguments that form the cache key.
* @param WC_Product product The product for which the key is being generated.
* @param bool display Indicates if the prices are being retrieved for display
* purposes.
* @return array
* @since WooCommerce 2.4
* @author Aelia <>
* @link
function disable_variation_prices_cache($cache_key_args, $product, $display) {
// Delete the cached data, if it exists
$cache_key = 'wc_var_prices' . md5(json_encode($cache_key_args));
return $cache_key_args;
add_filter('woocommerce_get_variation_prices_hash', 'disable_variation_prices_cache', 10, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment