Automattic\WooCommerce\Internal\ProductFilters
CacheController::clear_taxonomy_hierarchy_cache_on_meta_update
Clear taxonomy hierarchy cache when term meta is updated. This handles the case when categories are reordered (updates 'order' meta).
Method of the class: CacheController{}
No Hooks.
Returns
null. Nothing (null).
Usage
$CacheController = new CacheController(); $CacheController->clear_taxonomy_hierarchy_cache_on_meta_update( $meta_id, $term_id, $meta_key, $meta_value ): void;
- $meta_id(int) (required)
- Meta ID.
- $term_id(int) (required)
- Term ID.
- $meta_key(string) (required)
- Meta key.
- $meta_value(mixed) (required)
- Meta value.
CacheController::clear_taxonomy_hierarchy_cache_on_meta_update() CacheController::clear taxonomy hierarchy cache on meta update code WC 10.8.1
public function clear_taxonomy_hierarchy_cache_on_meta_update( $meta_id, $term_id, $meta_key, $meta_value ): void {
// Only clear cache when the 'order' meta key is updated (used for menu ordering).
if ( 'order' !== $meta_key ) {
return;
}
$term = get_term( $term_id );
if ( ! $term instanceof \WP_Term ) {
return;
}
$this->taxonomy_hierarchy_data->clear_cache( $term->taxonomy );
}