Automattic\WooCommerce\Internal\Caches

ProductVersionStringInvalidator::handle_transition_post_status │ public │ WC 10.6.0

Handle the transition_post_status hook.

Invalidates the product list version string when a product or variation changes status, as this may affect which products appear in collection endpoints.

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

Хуков нет.

Возвращает

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

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

$ProductVersionStringInvalidator = new ProductVersionStringInvalidator();
$ProductVersionStringInvalidator->handle_transition_post_status( $new_status, $old_status, $post ): void;
$new_status(строка) (обязательный)
The new post status.
$old_status(строка) (обязательный)
The old post status.
$post(WP_Post) (обязательный)
The post object.

Список изменений

С версии 10.6.0 Введена.

Код ProductVersionStringInvalidator::handle_transition_post_status() WC 11.2.2

public function handle_transition_post_status( $new_status, $old_status, $post ): void {
	if ( ! $post instanceof \WP_Post ) {
		return;
	}

	if ( $new_status === $old_status ) {
		return;
	}

	if ( 'product' === $post->post_type ) {
		$this->invalidate_products_list();
	} elseif ( 'product_variation' === $post->post_type ) {
		$this->invalidate_variations_list( (int) $post->post_parent );
	}
}