Automattic\WooCommerce\Internal\Caches
ProductCacheController::invalidate_product_cache_by_meta
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() 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 );
}
}