Automattic\WooCommerce\Internal\Caches
CouponCodeLookupInvalidator::handle_deleted_post
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.
Method of the class: CouponCodeLookupInvalidator{}
No Hooks.
Returns
void. Nothing (null).
Usage
$CouponCodeLookupInvalidator = new CouponCodeLookupInvalidator(); $CouponCodeLookupInvalidator->handle_deleted_post( $post_id, $post ): void;
- $post_id(int) (required)
- Post id.
- $post(WP_Post) (required)
- Post object.
Changelog
| Since 11.2.0 | Introduced. |
CouponCodeLookupInvalidator::handle_deleted_post() CouponCodeLookupInvalidator::handle deleted post code 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 );
}
}