Automattic\WooCommerce\Internal\DataStores\Orders

DataSynchronizer::sync_next_batch()privateWC 1.0

Processes a batch of out of sync orders. First it synchronizes orders that don't exist in the backup table, and after that, it synchronizes orders that exist in both tables but have a different last update date.

{} Это метод класса: DataSynchronizer{}

Возвращает

null. Ничего.

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

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

Код DataSynchronizer::sync_next_batch() WC 6.6.1

private function sync_next_batch(): void {
	/**
	 * Filter to customize the count of orders that will be synchronized in each step of the custom orders table to/from posts table synchronization process.
	 *
	 * @since 6.6.0
	 *
	 * @param int Default value for the count.
	 */
	$batch_size = apply_filters( 'woocommerce_orders_cot_and_posts_sync_step_size', self::ORDERS_SYNC_BATCH_SIZE );

	if ( $this->custom_orders_table_is_authoritative() ) {
		$order_ids = $this->get_ids_of_orders_pending_sync( self::ID_TYPE_MISSING_IN_POSTS_TABLE, $batch_size );
		// TODO: Load $order_ids orders from the orders table and create them (by updating the corresponding placeholder record) in the posts table.
	} else {
		$order_ids = $this->get_ids_of_orders_pending_sync( self::ID_TYPE_MISSING_IN_ORDERS_TABLE, $batch_size );
		$this->posts_to_cot_migrator->migrate_orders( $order_ids );
	}

	$batch_size -= count( $order_ids );
	if ( 0 === $batch_size ) {
		return;
	}

	$order_ids = $this->get_ids_of_orders_pending_sync( self::ID_TYPE_DIFFERENT_UPDATE_DATE, $batch_size );
	if ( 0 === count( $order_ids ) ) {
		return;
	}

	// phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedIf
	if ( $this->custom_orders_table_is_authoritative() ) {
		// TODO: Load $order_ids orders from the orders table and update them in the posts table.
	} else {
		$this->posts_to_cot_migrator->migrate_orders( $order_ids );
	}
}