WordPress at Your Fingertips
function is not described

WC_Post_Data::untrash_post() public WC 1.0

Untrash post.

{} It's a method of the class: WC_Post_Data{}

No Hooks.

Return

null. Nothing.

Usage

$result = WC_Post_Data::untrash_post( $id );
$id(mixed) (required)
Post ID.

Code of WC_Post_Data::untrash_post() WC 5.7.1

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' => 'wc-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 );

		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 );
	}
}