WC_Cart::get_cart_item_quantities()
Get cart items quantities – merged so we can do accurate stock checks on items across multiple lines.
Description Description
Return Return
(array)
Source Source
File: includes/class-wc-cart.php
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; }