WordPress at Your Fingertips
function is not described

Automattic\WooCommerce\Blocks\StoreApi\Utilities

CartController::get_cart_instance() public WC 1.0

Get main instance of cart class.

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

No Hooks.

Return

\WC_Cart.

Usage

$CartController = new CartController();
$CartController->get_cart_instance();

Code of CartController::get_cart_instance() WC 5.8.0

public function get_cart_instance() {
	$cart = wc()->cart;

	if ( ! $cart || ! $cart instanceof \WC_Cart ) {
		throw new RouteException( 'woocommerce_rest_cart_error', __( 'Unable to retrieve cart.', 'woocommerce' ), 500 );
	}

	return $cart;
}