/** * Simple read. */ public function __construct($id = '') { parent::__construct(); if (!empty($id)) { $this->read($id); } }
/** * Constructor. * @param int|object|array $read ID to load from the DB (optional) or already queried data. */ public function __construct($read = 0) { parent::__construct($read); if ($read instanceof WC_Order_Item) { if ($this->is_type($read->get_type())) { $this->set_props($read->get_data()); } } elseif (is_array($read)) { $this->set_props($read); } else { $this->read($read); } }
/** * Constructor. * @param int|object|array $item ID to load from the DB, or WC_Order_Item Object */ public function __construct($item = 0) { $this->data = array_merge($this->data, $this->extra_data); parent::__construct($item); if ($item instanceof WC_Order_Item) { $this->set_id($item->get_id()); } elseif (is_numeric($item) && $item > 0) { $this->set_id($item); } else { $this->set_object_read(true); } $type = 'line_item' === $this->get_type() ? 'product' : $this->get_type(); $this->data_store = WC_Data_Store::load('order-item-' . $type); if ($this->get_id() > 0) { $this->data_store->read($this); } }
/** * Constructor. * * @param int|object|array $download */ public function __construct($download = 0) { parent::__construct($download); if (is_numeric($download) && $download > 0) { $this->set_id($download); } elseif ($download instanceof self) { $this->set_id($download->get_id()); } elseif (is_object($download) && !empty($download->permission_id)) { $this->set_id($download->permission_id); $this->set_props((array) $download); $this->set_object_read(true); } else { $this->set_object_read(true); } $this->data_store = WC_Data_Store::load('customer-download'); if ($this->get_id() > 0) { $this->data_store->read($this); } }
/** * Simple read. */ public function __construct($id = '') { parent::__construct(); if (!empty($id)) { $this->set_id($id); } else { $this->set_object_read(true); } $this->data_store = new WC_Mock_WC_Data_Store(); if ($this->get_id() > 0) { $this->data_store->read($this); } }