WC_Cache_Helper::clean_term_cache( array|int $ids, string $taxonomy )
Clean term caches added by WooCommerce.
Description Description
Parameters Parameters
- $ids
-
(Required) Array of ids or single ID to clear cache for.
- $taxonomy
-
(Required) Taxonomy name.
Source Source
File: includes/class-wc-cache-helper.php
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' );
}
}
}
Changelog Changelog
| Version | Description |
|---|---|
| 3.3.4 | Introduced. |