Automattic\WooCommerce\Admin
ReportsSync::maybe_clear_stock_count_cache_for_post
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.
Method of the class: ReportsSync{}
No Hooks.
Returns
null. Nothing (null).
Usage
$result = ReportsSync::maybe_clear_stock_count_cache_for_post( $post_id ): void;
- $post_id(int) (required)
- The post ID.
ReportsSync::maybe_clear_stock_count_cache_for_post() ReportsSync::maybe clear stock count cache for post code WC 10.7.0
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 );
}
}