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.


Top ↑

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' );
			}
		}
	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.3.4 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.