WC_Order_Item::__construct PHP Method

__construct() public method

Constructor.
public __construct ( integer | object | array $item )
$item integer | object | array 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);
        }
    }