WC_Cart::get_cart_contents_count()publicWC 1.0

Get number of items in the cart.

Method of the class: WC_Cart{}

Hooks from the method

Return

Int.

Usage

$WC_Cart = new WC_Cart();
$WC_Cart->get_cart_contents_count();

WC_Cart::get_cart_contents_count() code WC 9.4.2

public function get_cart_contents_count() {
	return apply_filters( 'woocommerce_cart_contents_count', array_sum( wp_list_pluck( $this->get_cart(), 'quantity' ) ) );
}