WC_Cart::get_cart_contents_count()publicWC 1.0

Get number of items in the cart.

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

Hooks from the method

Return

Int.

Usage

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

Code of WC_Cart::get_cart_contents_count() WC 6.7.0

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