Automattic\WooCommerce\Database\Migrations\CustomOrderTable
PostsToOrdersMigrationController::migrate_orders()
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() PostsToOrdersMigrationController::migrate orders code WC 9.7.1
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(); } $this->maybe_clear_order_datastore_cache_for_ids( $order_post_ids ); }