Automattic\WooCommerce\Caches

ProductCountCacheService::update_on_product_deletedpublicWC 1.0

Update the cache when a product is permanently deleted.

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

Хуков нет.

Возвращает

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

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

$ProductCountCacheService = new ProductCountCacheService();
$ProductCountCacheService->update_on_product_deleted( $post_id, $post ): void;
$post_id(int) (обязательный)
Post ID.
$post(WP_Post) (обязательный)
The post object.

Код ProductCountCacheService::update_on_product_deleted() WC 11.0.1

public function update_on_product_deleted( int $post_id, WP_Post $post ): void {
	if ( 'product' === $post->post_type ) {
		// Reverse any errant decrement from a mid-creation status transition that update_on_new_product will never get to correct.
		$this->maybe_restore_initial_status_count( $post_id );

		$product_status = $post->post_status;
		if ( $this->product_count_cache->is_cached( 'product', $product_status ) ) {
			$this->product_count_cache->decrement( 'product', $product_status );
		}

		unset( $this->product_statuses[ $post_id ], $this->products_in_creation[ $post_id ] );
	}
}