Automattic\WooCommerce\Admin

ReportsSync::maybe_clear_stock_count_cache_for_postpublic staticWC 1.0

Clear the stock count cache for a post if it's a product or product variation.

Handles trashed_post, untrashed_post, and delete_post hooks.

Метод класса: ReportsSync{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$result = ReportsSync::maybe_clear_stock_count_cache_for_post( $post_id ): void;
$post_id(int) (обязательный)
The post ID.

Код ReportsSync::maybe_clear_stock_count_cache_for_post() WC 10.8.1

public static function maybe_clear_stock_count_cache_for_post( $post_id ): void {
	$post = get_post( $post_id );
	if ( $post && in_array( $post->post_type, array( 'product', 'product_variation' ), true ) ) {
		self::clear_stock_count_cache( $post_id );
	}
}