Automattic\WooCommerce\StoreApi\Utilities
CartController::get_cart_instance()
Get main instance of cart class.
Method of the class: CartController{}
No Hooks.
Return
\WC_Cart
.
Usage
$CartController = new CartController(); $CartController->get_cart_instance();
CartController::get_cart_instance() CartController::get cart instance code WC 9.2.3
public function get_cart_instance() { $cart = wc()->cart; if ( ! $cart || ! $cart instanceof \WC_Cart ) { throw new RouteException( 'woocommerce_rest_cart_error', esc_html__( 'Unable to retrieve cart.', 'woocommerce' ), 500 ); } return $cart; }