Automattic\WooCommerce\Database\Migrations\CustomOrderTable

PostsToOrdersMigrationController::migrate_orders()publicWC 1.0

Migrates a set of orders from the posts table to the custom orders tables.

Method of the class: PostsToOrdersMigrationController{}

No Hooks.

Return

null. Nothing (null).

Usage

$PostsToOrdersMigrationController = new PostsToOrdersMigrationController();
$PostsToOrdersMigrationController->migrate_orders( $order_post_ids ): void;
$order_post_ids(array) (required)
List of post IDs of the orders to migrate.

PostsToOrdersMigrationController::migrate_orders() code WC 8.9.0

public function migrate_orders( array $order_post_ids ): void {
	$this->error_logger = WC()->call_function( 'wc_get_logger' );

	$data = array();
	try {
		foreach ( $this->all_migrators as $name => $migrator ) {
			$data[ $name ] = $migrator->fetch_sanitized_migration_data( $order_post_ids );
			if ( ! empty( $data[ $name ]['errors'] ) ) {
				$this->handle_migration_error( $order_post_ids, $data[ $name ]['errors'], null, null, $name );
				return;
			}
		}
	} catch ( \Exception $e ) {
		$this->handle_migration_error( $order_post_ids, $data, $e, null, 'Fetching data' );
		return;
	}

	$using_transactions = $this->maybe_start_transaction();

	foreach ( $this->all_migrators as $name => $migrator ) {
		$results   = $migrator->process_migration_data( $data[ $name ] );
		$errors    = array_unique( $results['errors'] );
		$exception = $results['exception'];

		if ( null === $exception && empty( $errors ) ) {
			continue;
		}

		$this->handle_migration_error( $order_post_ids, $errors, $exception, $using_transactions, $name );
		return;
	}

	if ( $using_transactions ) {
		$this->commit_transaction();
	}

}