WordPress at Your Fingertips
function is not described

Automattic\WooCommerce\Blocks\StoreApi\Utilities

OrderController::create_order_from_cart() public WC 1.0

Create order and set props based on global settings.

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

No Hooks.

Return

\WC_Order. A new order object.

Usage

$OrderController = new OrderController();
$OrderController->create_order_from_cart();

Code of OrderController::create_order_from_cart() WC 5.8.0

public function create_order_from_cart() {
	if ( wc()->cart->is_empty() ) {
		throw new RouteException(
			'woocommerce_rest_cart_empty',
			__( 'Cannot create order from empty cart.', 'woocommerce' ),
			400
		);
	}

	add_filter( 'woocommerce_default_order_status', array( $this, 'default_order_status' ) );

	$order = new \WC_Order();
	$order->set_status( 'checkout-draft' );
	$order->set_created_via( 'store-api' );
	$this->update_order_from_cart( $order );

	remove_filter( 'woocommerce_default_order_status', array( $this, 'default_order_status' ) );

	return $order;
}