WordPress at Your Fingertips
function is not described

Abstract_WC_Order_Data_Store_CPT::read_items() public WC 1.0

Read order items of a specific type from the database for this order.

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

No Hooks.

Return

Array.

Usage

$Abstract_WC_Order_Data_Store_CPT = new Abstract_WC_Order_Data_Store_CPT();
$Abstract_WC_Order_Data_Store_CPT->read_items( $order, $type );
$order(WC_Order) (required)
Order object.
$type(string) (required)
Order item type.

Code of Abstract_WC_Order_Data_Store_CPT::read_items() WC 5.6.0

public function read_items( $order, $type ) {
	global $wpdb;

	// Get from cache if available.
	$items = 0 < $order->get_id() ? wp_cache_get( 'order-items-' . $order->get_id(), 'orders' ) : false;

	if ( false === $items ) {
		$items = $wpdb->get_results(
			$wpdb->prepare( "SELECT order_item_type, order_item_id, order_id, order_item_name FROM {$wpdb->prefix}woocommerce_order_items WHERE order_id = %d ORDER BY order_item_id;", $order->get_id() )
		);
		foreach ( $items as $item ) {
			wp_cache_set( 'item-' . $item->order_item_id, $item, 'order-items' );
		}
		if ( 0 < $order->get_id() ) {
			wp_cache_set( 'order-items-' . $order->get_id(), $items, 'orders' );
		}
	}

	$items = wp_list_filter( $items, array( 'order_item_type' => $type ) );

	if ( ! empty( $items ) ) {
		$items = array_map( array( 'WC_Order_Factory', 'get_order_item' ), array_combine( wp_list_pluck( $items, 'order_item_id' ), $items ) );
	} else {
		$items = array();
	}

	return $items;
}