WC_Order_Item_Shipping_Data_Store::read()publicWC 3.0.0

Read/populate data properties specific to this order item.

Method of the class: WC_Order_Item_Shipping_Data_Store{}

No Hooks.

Return

null. Nothing (null).

Usage

$WC_Order_Item_Shipping_Data_Store = new WC_Order_Item_Shipping_Data_Store();
$WC_Order_Item_Shipping_Data_Store->read( $item );
$item(WC_Order_Item_Shipping) (required) (passed by reference — &)
Item to read to.

Changelog

Since 3.0.0 Introduced.

WC_Order_Item_Shipping_Data_Store::read() code WC 9.4.2

public function read( &$item ) {
	parent::read( $item );
	$id = $item->get_id();
	$item->set_props(
		array(
			'method_id'   => get_metadata( 'order_item', $id, 'method_id', true ),
			'instance_id' => get_metadata( 'order_item', $id, 'instance_id', true ),
			'total'       => get_metadata( 'order_item', $id, 'cost', true ),
			'taxes'       => get_metadata( 'order_item', $id, 'taxes', true ),
		)
	);

	// BW compat.
	if ( '' === $item->get_instance_id() && strstr( $item->get_method_id(), ':' ) ) {
		$legacy_method_id = explode( ':', $item->get_method_id() );
		$item->set_method_id( $legacy_method_id[0] );
		$item->set_instance_id( $legacy_method_id[1] );
	}

	$item->set_object_read( true );
}