WC_Cart::get_cart_for_session PHP Method

get_cart_for_session() public method

Returns the contents of the cart in an array without the 'data' element.
public get_cart_for_session ( ) : array
return array contents of the cart
    public function get_cart_for_session()
    {
        $cart_session = array();
        if ($this->get_cart()) {
            foreach ($this->get_cart() as $key => $values) {
                $cart_session[$key] = $values;
                unset($cart_session[$key]['data']);
                // Unset product object
            }
        }
        return $cart_session;
    }
WC_Cart