WC_Order_Item::__construct()publicWC 1.0

Constructor.

Method of the class: WC_Order_Item{}

No Hooks.

Return

null. Nothing (null).

Usage

$WC_Order_Item = new WC_Order_Item();
$WC_Order_Item->__construct( $item );
$item(int|object|array)
ID to load from the DB, or WC_Order_Item object.

WC_Order_Item::__construct() code WC 8.7.0

public function __construct( $item = 0 ) {
	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 );
	}
}