WC_Post_Data::trash_post()
Trash post.
Метод класса: WC_Post_Data{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
$result = WC_Post_Data::trash_post( $id );
- $id(разное) (обязательный)
- Post ID.
Код WC_Post_Data::trash_post() WC Post Data::trash post WC 9.6.1
public static function trash_post( $id ) { if ( ! $id ) { return; } $post_type = self::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' => OrderStatus::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 ); wc_get_container()->get( ProductAttributesLookupDataStore::class )->on_product_deleted( $id ); } elseif ( 'product_variation' === $post_type ) { wc_get_container()->get( ProductAttributesLookupDataStore::class )->on_product_deleted( $id ); } }