Automattic\WooCommerce\Internal\Caches

ProductCacheController::invalidate_product_cache_by_metapublicWC 10.5.0

Invalidate the product cache when post meta is updated.

Method of the class: ProductCacheController{}

No Hooks.

Returns

null. Nothing (null).

Usage

$ProductCacheController = new ProductCacheController();
$ProductCacheController->invalidate_product_cache_by_meta( $meta_id, $object_id ): void;
$meta_id(int) (required)
The ID of the metadata entry.
$object_id(int) (required)
The ID of the object the metadata is for.

Changelog

Since 10.5.0 Introduced.

ProductCacheController::invalidate_product_cache_by_meta() code WC 10.7.0

public function invalidate_product_cache_by_meta( $meta_id, $object_id ): void {
	$object_id = (int) $object_id;
	if ( in_array( get_post_type( $object_id ), array( 'product', 'product_variation' ), true ) ) {
		$this->invalidate_product_cache( $object_id );
	}
}