Automattic\WooCommerce\Internal\DataStores\Orders

DataSynchronizer::process_batch()publicWC 1.0

Process data for current batch.

Method of the class: DataSynchronizer{}

No Hooks.

Return

null. Nothing (null).

Usage

$DataSynchronizer = new DataSynchronizer();
$DataSynchronizer->process_batch( $batch ): void;
$batch(array) (required)
Batch details.

DataSynchronizer::process_batch() code WC 9.3.3

public function process_batch( array $batch ): void {
	if ( empty( $batch ) ) {
		return;
	}

	$batch = array_map( 'absint', $batch );

	$this->order_cache_controller->temporarily_disable_orders_cache_usage();

	$custom_orders_table_is_authoritative = $this->custom_orders_table_is_authoritative();
	$deleted_order_ids                    = $this->process_deleted_orders( $batch, $custom_orders_table_is_authoritative );
	$batch                                = array_diff( $batch, $deleted_order_ids );

	if ( ! empty( $batch ) ) {
		if ( $custom_orders_table_is_authoritative ) {
			foreach ( $batch as $id ) {
				$order = wc_get_order( $id );
				if ( ! $order ) {
					$this->error_logger->error( "Order $id not found during batch process, skipping." );
					continue;
				}
				$data_store = $order->get_data_store();
				$data_store->backfill_post_record( $order );
			}
		} else {
			$this->posts_to_cot_migrator->migrate_orders( $batch );
		}
	}

	if ( 0 === $this->get_total_pending_count() ) {
		$this->cleanup_synchronization_state();
		$this->order_cache_controller->maybe_restore_orders_cache_usage();
	}
}