WordPress at Your Fingertips
function is not described

WC_Cart::get_cart_item_quantities() public WC 1.0

Get cart items quantities - merged so we can do accurate stock checks on items across multiple lines.

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

No Hooks.

Return

Array.

Usage

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

Code of WC_Cart::get_cart_item_quantities() WC 5.7.1

public function get_cart_item_quantities() {
	$quantities = array();

	foreach ( $this->get_cart() as $cart_item_key => $values ) {
		$product = $values['data'];
		$quantities[ $product->get_stock_managed_by_id() ] = isset( $quantities[ $product->get_stock_managed_by_id() ] ) ? $quantities[ $product->get_stock_managed_by_id() ] + $values['quantity'] : $values['quantity'];
	}

	return $quantities;
}