WC_Order_Item::__construct
Constructor.
Метод класса: WC_Order_Item{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$WC_Order_Item = new WC_Order_Item(); $WC_Order_Item->__construct( $item );
- $item(int|объект|массив)
- ID to load from the DB, or WC_Order_Item object.
Код WC_Order_Item::__construct() WC Order Item:: construct WC 10.7.0
public function __construct( $item = 0 ) {
if ( $this->has_cogs() && $this->cogs_is_enabled() ) {
$this->data['cogs_value'] = null;
}
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 );
}
if ( $this->get_id() && __CLASS__ === get_class( $this ) ) {
wc_doing_it_wrong( __METHOD__, 'WC_Order_Item should not be instantiated directly.', '9.9.0' );
return;
}
$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 );
}
}