new WC_Order($order_id); Constructor disappeared

After the last update on Woocommerce that occurred yesterday instantiating the constructor of class WC_Order is not working anymore as it got removed. What alternative can I use of the code below:


class ThemexWoo {
    public static function getRelatedPost($ID, $type, $single=false) {
        $order = new WC_Order($ID);
        if(!empty($products)) {
            $ID=wp_list_pluck($products, 'product_id');

        $relations=array_merge(array(0), ThemexCore::getPostRelations(0, $ID, $type));
            'numberposts' => -1,
            'post_type' => array('course', 'plan'),
            'post__in' => $relations,

        if(!empty($posts)) {
            if($order->user_id) {
                foreach($posts as &$post) {

            if($single) {

        return $posts;


global $woocommerce;
$related=ThemexWoo::getRelatedPost($product['product_id'], array('course_product', 'plan_product'), true);

Read more here: new WC_Order($order_id); Constructor disappeared

Leave a Reply

Your email address will not be published. Required fields are marked *