WC_Post_Data::trash_post( mixed $id )
Trash post.
Description Description
Parameters Parameters
- $id
-
(Required) Post ID.
Source Source
File: includes/class-wc-post-data.php
public static function trash_post( $id ) { if ( ! $id ) { return; } $post_type = get_post_type( $id ); // If this is an order, trash any refunds too. if ( in_array( $post_type, wc_get_order_types( 'order-count' ), true ) ) { global $wpdb; $refunds = $wpdb->get_results( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = 'shop_order_refund' AND post_parent = %d", $id ) ); foreach ( $refunds as $refund ) { $wpdb->update( $wpdb->posts, array( 'post_status' => 'trash' ), array( 'ID' => $refund->ID ) ); } wc_delete_shop_order_transients( $id ); // If this is a product, trash children variations. } elseif ( 'product' === $post_type ) { $data_store = WC_Data_Store::load( 'product-variable' ); $data_store->delete_variations( $id, false ); } }