Automattic\WooCommerce\Blocks\BlockTypes

MiniCart::get_cart_instance()protectedWC 1.0

Return the main instance of WC_Cart class.

Method of the class: MiniCart{}

No Hooks.

Return

\WC_Cart. CartController class instance.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_cart_instance();

MiniCart::get_cart_instance() code WC 9.4.2

protected function get_cart_instance() {
	$cart = WC()->cart;

	if ( $cart && $cart instanceof \WC_Cart ) {
		return $cart;
	}

	return null;
}