WC_Cache_Helper::clean_term_cache()
Clean term caches added by WooCommerce.
Method of the class: WC_Cache_Helper{}
No Hooks.
Return
null
. Nothing (null).
Usage
$result = WC_Cache_Helper::clean_term_cache( $ids, $taxonomy );
- $ids(array|int) (required)
- Array of ids or single ID to clear cache for.
- $taxonomy(string) (required)
- Taxonomy name.
Changelog
Since 3.3.4 | Introduced. |
WC_Cache_Helper::clean_term_cache() WC Cache Helper::clean term cache code WC 8.6.1
public static function clean_term_cache( $ids, $taxonomy ) { if ( 'product_cat' === $taxonomy ) { $ids = is_array( $ids ) ? $ids : array( $ids ); $clear_ids = array( 0 ); foreach ( $ids as $id ) { $clear_ids[] = $id; $clear_ids = array_merge( $clear_ids, get_ancestors( $id, 'product_cat', 'taxonomy' ) ); } $clear_ids = array_unique( $clear_ids ); foreach ( $clear_ids as $id ) { wp_cache_delete( 'product-category-hierarchy-' . $id, 'product_cat' ); } } }