WC_Abstract_Order::get_items( string|array $types = 'line_item' )

Return an array of items/products within this order.


Description Description


Parameters Parameters

$types

(Optional) Types of line items to get (array or string).

Default value: 'line_item'


Top ↑

Return Return

(WC_Order_Item[])


Top ↑

Source Source

File: includes/abstracts/abstract-wc-order.php

	public function get_items( $types = 'line_item' ) {
		$items = array();
		$types = array_filter( (array) $types );

		foreach ( $types as $type ) {
			$group = $this->type_to_group( $type );

			if ( $group ) {
				if ( ! isset( $this->items[ $group ] ) ) {
					$this->items[ $group ] = array_filter( $this->data_store->read_items( $this, $type ) );
				}
				// Don't use array_merge here because keys are numeric.
				$items = $items + $this->items[ $group ];
			}
		}

		return apply_filters( 'woocommerce_order_get_items', $items, $this, $types );
	}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.