diff --git a/includes/data-stores/class-wc-product-data-store-cpt.php b/includes/data-stores/class-wc-product-data-store-cpt.php index 6dfa7bdeb44..0ae3b5f3b5b 100644 --- a/includes/data-stores/class-wc-product-data-store-cpt.php +++ b/includes/data-stores/class-wc-product-data-store-cpt.php @@ -760,6 +760,7 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da */ protected function clear_caches( &$product ) { wc_delete_product_transients( $product->get_id() ); + WC_Cache_Helper::incr_cache_prefix( 'product_' . $product->get_id() ); } /* diff --git a/includes/wc-term-functions.php b/includes/wc-term-functions.php index 23decfead94..0249cd6c862 100644 --- a/includes/wc-term-functions.php +++ b/includes/wc-term-functions.php @@ -51,8 +51,9 @@ function wc_get_object_terms( $object_id, $taxonomy, $field = null, $index_key = * @return array */ function _wc_get_cached_product_terms( $product_id, $taxonomy, $args = array() ) { - $cache_key = 'wc_' . $taxonomy . md5( json_encode( $args ) ); - $terms = wp_cache_get( $product_id, $cache_key ); + $cache_key = 'wc_' . $taxonomy . md5( json_encode( $args ) ); + $cache_group = WC_Cache_Helper::get_cache_prefix( 'product_' . $product_id ) . $product_id; + $terms = wp_cache_get( $cache_key, $cache_group ); if ( false !== $terms ) { return $terms; @@ -62,7 +63,7 @@ function _wc_get_cached_product_terms( $product_id, $taxonomy, $args = array() ) $terms = wp_get_post_terms( $product_id, $taxonomy, $args ); // @codingStandardsIgnoreEnd - wp_cache_add( $product_id, $terms, $cache_key ); + wp_cache_add( $cache_key, $terms, $cache_group ); return $terms; }