Exposing current Commerce2 Cart via the Element API
The cart is not baked into \Craft, but craft\commerce\Plugin.

Try the following:

$cart = craft\commerce\Plugin::getInstance()-&gt;getCarts()-&gt;getCart();


Uses the following function:

/**
 * Get the current cart for this session.
 *
 * @param bool $forceSave Force the cart to save when requesting it.
 * @return Order
 * @throws Exception
 * @throws \Throwable
 * @throws \craft\errors\ElementNotFoundException
 */
public function getCart($forceSave = false): Order