Automattic\WooCommerce\Internal\Admin\Orders

PageController::register_menu()publicWC 1.0

Registers the "Orders" menu.

Method of the class: PageController{}

No Hooks.

Return

null. Nothing (null).

Usage

$PageController = new PageController();
$PageController->register_menu(): void;

PageController::register_menu() code WC 8.7.0

public function register_menu(): void {
	$order_types = wc_get_order_types( 'admin-menu' );

	foreach ( $order_types as $order_type ) {
		$post_type = get_post_type_object( $order_type );

		add_submenu_page(
			'woocommerce',
			$post_type->labels->name,
			$post_type->labels->menu_name,
			$post_type->cap->edit_posts,
			'wc-orders' . ( 'shop_order' === $order_type ? '' : '--' . $order_type ),
			array( $this, 'output' )
		);
	}

	// In some cases (such as if the authoritative order store was changed earlier in the current request) we
	// need an extra step to remove the menu entry for the menu post type.
	add_action(
		'admin_init',
		function() use ( $order_types ) {
			foreach ( $order_types as $order_type ) {
				remove_submenu_page( 'woocommerce', 'edit.php?post_type=' . $order_type );
			}
		}
	);
}