WordPress at Your Fingertips
function is not described

WC_Order_Item::__construct() public WC 1.0

Constructor.

{} It's a method of the class: WC_Order_Item{}

No Hooks.

Return

null. Nothing.

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.

Code of WC_Order_Item::__construct() WC 5.6.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 );
	}
}