WC_Post_Data::untrash_post
Untrash post.
Method of the class: WC_Post_Data{}
No Hooks.
Returns
null. Nothing (null).
Usage
$result = WC_Post_Data::untrash_post( $id );
- $id(mixed) (required)
- Post ID.
WC_Post_Data::untrash_post() WC Post Data::untrash post code WC 10.3.6
public static function untrash_post( $id ) {
if ( ! $id ) {
return;
}
$post_type = self::get_post_type( $id );
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' => OrderInternalStatus::COMPLETED ), array( 'ID' => $refund->ID ) );
}
wc_delete_shop_order_transients( $id );
} elseif ( 'product' === $post_type ) {
$data_store = WC_Data_Store::load( 'product-variable' );
$data_store->untrash_variations( $id );
wc_product_force_unique_sku( $id );
self::clear_global_unique_id_if_necessary( $id );
wc_get_container()->get( ProductAttributesLookupDataStore::class )->on_product_changed( $id );
} elseif ( 'product_variation' === $post_type ) {
wc_get_container()->get( ProductAttributesLookupDataStore::class )->on_product_changed( $id );
}
}