WC_Abstract_Order::get_item_count( string $item_type = '' )

Gets the count of order items of a certain type.


Description Description


Parameters Parameters

$item_type

(Optional) Item type to lookup.

Default value: ''


Top ↑

Return Return

(int|string)


Top ↑

Source Source

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

	public function get_item_count( $item_type = '' ) {
		$items = $this->get_items( empty( $item_type ) ? 'line_item' : $item_type );
		$count = 0;

		foreach ( $items as $item ) {
			$count += $item->get_quantity();
		}

		return apply_filters( 'woocommerce_get_item_count', $count, $item_type, $this );
	}


Top ↑

User Contributed Notes User Contributed Notes

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