Automattic\WooCommerce\Internal\Caches

CouponCodeLookupInvalidator::handle_deleted_post │ public │ WC 11.2.0

Delete the lookup entry of a published coupon post that is deleted.

The core data store only caches published coupons, so deleting a coupon in any other status cannot strand one of its entries. A custom data store can cache other statuses too, which is why WC_Coupon_Data_Store_CPT::delete() also invalidates on force delete.

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

Хуков нет.

Возвращает

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

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

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

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

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

Код CouponCodeLookupInvalidator::handle_deleted_post() WC 11.3.0

public function handle_deleted_post( $post_id, $post ): void {
	if ( $post instanceof \WP_Post && 'shop_coupon' === $post->post_type && 'publish' === $post->post_status ) {
		$this->invalidate( $post->post_title );
	}
}