parent
f8552ebbad
commit
a467d35acd
|
@ -760,6 +760,7 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
|
||||||
*/
|
*/
|
||||||
protected function clear_caches( &$product ) {
|
protected function clear_caches( &$product ) {
|
||||||
wc_delete_product_transients( $product->get_id() );
|
wc_delete_product_transients( $product->get_id() );
|
||||||
|
WC_Cache_Helper::incr_cache_prefix( 'product_' . $product->get_id() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -51,8 +51,9 @@ function wc_get_object_terms( $object_id, $taxonomy, $field = null, $index_key =
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function _wc_get_cached_product_terms( $product_id, $taxonomy, $args = array() ) {
|
function _wc_get_cached_product_terms( $product_id, $taxonomy, $args = array() ) {
|
||||||
$cache_key = 'wc_' . $taxonomy . md5( json_encode( $args ) );
|
$cache_key = 'wc_' . $taxonomy . md5( json_encode( $args ) );
|
||||||
$terms = wp_cache_get( $product_id, $cache_key );
|
$cache_group = WC_Cache_Helper::get_cache_prefix( 'product_' . $product_id ) . $product_id;
|
||||||
|
$terms = wp_cache_get( $cache_key, $cache_group );
|
||||||
|
|
||||||
if ( false !== $terms ) {
|
if ( false !== $terms ) {
|
||||||
return $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 );
|
$terms = wp_get_post_terms( $product_id, $taxonomy, $args );
|
||||||
// @codingStandardsIgnoreEnd
|
// @codingStandardsIgnoreEnd
|
||||||
|
|
||||||
wp_cache_add( $product_id, $terms, $cache_key );
|
wp_cache_add( $cache_key, $terms, $cache_group );
|
||||||
|
|
||||||
return $terms;
|
return $terms;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue