WC_Order_Item::__construct( int|object|array $item )
Constructor.
Description Description
Parameters Parameters
- $item
-
(Required) ID to load from the DB, or WC_Order_Item object.
Source Source
File: includes/class-wc-order-item.php
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 ); } }