/** * Get the order if ID is passed, otherwise the order is new and empty. * This class should NOT be instantiated, but the get_order function or new WC_Order_Factory. * should be used. It is possible, but the aforementioned are preferred and are the only. * methods that will be maintained going forward. * * @param int|object|WC_Order $read Order to init. */ public function __construct($read = 0) { parent::__construct($read); if (is_numeric($read) && $read > 0) { $this->read($read); } elseif ($read instanceof self) { $this->read(absint($read->get_id())); } elseif (!empty($read->ID)) { $this->read(absint($read->ID)); } // Set default status if none were read. if (!$this->get_status()) { $this->set_status(apply_filters('woocommerce_default_order_status', 'pending')); } }
/** * Get the order if ID is passed, otherwise the order is new and empty. * This class should NOT be instantiated, but the get_order function or new WC_Order_Factory. * should be used. It is possible, but the aforementioned are preferred and are the only. * methods that will be maintained going forward. * * @param int|object|WC_Order $order Order to read. */ public function __construct($order = 0) { parent::__construct($order); if (is_numeric($order) && $order > 0) { $this->set_id($order); } elseif ($order instanceof self) { $this->set_id($order->get_id()); } elseif (!empty($order->ID)) { $this->set_id($order->ID); } else { $this->set_object_read(true); } // Set default status if none were read. if (!$this->get_status()) { $this->set_status(apply_filters('woocommerce_default_order_status', 'pending')); } $this->data_store = WC_Data_Store::load($this->data_store_name); if ($this->get_id() > 0) { $this->data_store->read($this); } }