Automattic\WooCommerce\Internal\Admin\Orders

PageController::setup_action_new_order()privateWC 1.0

Handles initialization of the orders edit form with a new order.

Метод класса: PageController{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

// private - только в коде основоного (родительского) класса
$result = $this->setup_action_new_order(): void;

Код PageController::setup_action_new_order() WC 8.6.1

private function setup_action_new_order(): void {
	global $theorder;

	$this->verify_create_permission();

	$order_class_name = wc_get_order_type( $this->order_type )['class_name'];
	if ( ! $order_class_name || ! class_exists( $order_class_name ) ) {
		wp_die();
	}

	$this->order = new $order_class_name();
	$this->order->set_object_read( false );
	$this->order->set_status( 'auto-draft' );
	$this->order->set_created_via( 'admin' );
	$this->order->save();
	$this->handle_edit_lock();

	// Schedule auto-draft cleanup. We re-use the WP event here on purpose.
	if ( ! wp_next_scheduled( 'wp_scheduled_auto_draft_delete' ) ) {
		wp_schedule_event( time(), 'daily', 'wp_scheduled_auto_draft_delete' );
	}

	$theorder = $this->order;

	$this->prepare_order_edit_form();
}