Automattic\WooCommerce\StoreApi\Utilities

CartController::load_cartpublicWC 1.0

Makes the cart and sessions available to a route by loading them from core.

Method of the class: CartController{}

No Hooks.

Returns

null. Nothing (null).

Usage

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

CartController::load_cart() code WC 9.9.3

public function load_cart() {
	if ( did_action( 'woocommerce_load_cart_from_session' ) ) {
		return;
	}

	// Initialize the cart.
	wc_load_cart();

	// Load cart from session.
	$cart               = $this->get_cart_instance();
	$cart->cart_context = 'store-api';
	$cart->get_cart();
}