WC_Webhook::is_valid_variation_delete_action
Validates permanent deletions for product webhooks: only variations, skipping those already reported.
Trashing through wp_trash_post() fires product.deleted and records _wp_trash_meta_status, so a variation trashed that way is not reported again when it is permanently deleted.
Method of the class: WC_Webhook{}
No Hooks.
Returns
bool. True if validation passes.
Usage
// private - for code of main (parent) class only $result = $this->is_valid_variation_delete_action( $arg );
- $arg(mixed) (required)
- First hook argument.
Changelog
| Since 11.3.0 | Introduced. |
WC_Webhook::is_valid_variation_delete_action() WC Webhook::is valid variation delete action code WC 11.3.0
private function is_valid_variation_delete_action( $arg ) {
if ( 'product' !== $this->get_resource() ) {
return true;
}
if ( ! $this->is_valid_post_action( $arg ) ) {
return false;
}
$variation_id = absint( $arg );
if ( 'product_variation' !== get_post_type( $variation_id ) ) {
return false;
}
return ProductStatus::TRASH !== get_post_status( $variation_id ) || ! metadata_exists( 'post', $variation_id, '_wp_trash_meta_status' );
}