Automattic\WooCommerce\Internal\Caches
ProductCacheController::invalidate_product_cache
Invalidate the product cache for a given post ID if it's a product or product variation.
Метод класса: ProductCacheController{}
Хуков нет.
Возвращает
void. Ничего (null).
Использование
$ProductCacheController = new ProductCacheController(); $ProductCacheController->invalidate_product_cache( $post_id ): void;
- $post_id(int) (обязательный)
- The post ID to check and invalidate.
Список изменений
| С версии 10.5.0 | Введена. |
Код ProductCacheController::invalidate_product_cache() ProductCacheController::invalidate product cache WC 11.2.2
public function invalidate_product_cache( $post_id ): void {
$post_id = (int) $post_id;
$post_type = get_post_type( $post_id );
if ( ! $post_type || ! in_array( $post_type, array( 'product', 'product_variation' ), true ) ) {
return;
}
$this->product_cache->remove( $post_id );
}