WordPress at Your Fingertips
function is not described

Abstract_WC_Order_Item_Type_Data_Store::read() public WC 3.0.0

Read a order item from the database.

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

No Hooks.

Return

null. Nothing.

Usage

$Abstract_WC_Order_Item_Type_Data_Store = new Abstract_WC_Order_Item_Type_Data_Store();
$Abstract_WC_Order_Item_Type_Data_Store->read( $item );
$item(WC_Order_Item) (required) (passed by reference — &)
Order item object.

Changelog

Since 3.0.0 Introduced.

Code of Abstract_WC_Order_Item_Type_Data_Store::read() WC 5.7.0

public function read( &$item ) {
	global $wpdb;

	$item->set_defaults();

	// Get from cache if available.
	$data = wp_cache_get( 'item-' . $item->get_id(), 'order-items' );

	if ( false === $data ) {
		$data = $wpdb->get_row( $wpdb->prepare( "SELECT order_id, order_item_name FROM {$wpdb->prefix}woocommerce_order_items WHERE order_item_id = %d LIMIT 1;", $item->get_id() ) );
		wp_cache_set( 'item-' . $item->get_id(), $data, 'order-items' );
	}

	if ( ! $data ) {
		throw new Exception( __( 'Invalid order item.', 'woocommerce' ) );
	}

	$item->set_props(
		array(
			'order_id' => $data->order_id,
			'name'     => $data->order_item_name,
		)
	);
	$item->read_meta_data();
}