WC_Post_Data::untrash_post PHP Method

untrash_post() public static method

woocommerce_untrash_post function.
public static untrash_post ( mixed $id )
$id mixed
    public static function untrash_post($id)
    {
        global $wpdb;
        if ($id > 0) {
            $post_type = get_post_type($id);
            if (in_array($post_type, wc_get_order_types('order-count'))) {
                $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));
                }
                delete_transient('woocommerce_processing_order_count');
                wc_delete_shop_order_transients($id);
            } elseif ('product' === $post_type) {
                // Check if SKU is valid before untrash the product.
                $sku = get_post_meta($id, '_sku', true);
                if (!empty($sku)) {
                    if (!wc_product_has_unique_sku($id, $sku)) {
                        update_post_meta($id, '_sku', '');
                    }
                }
            }
        }
    }