Automattic\WooCommerce\Internal\DataStores\Orders

DataSynchronizer::get_next_batch_to_process()publicWC 1.0

Returns the batch with records that needs to be processed for a given size.

Method of the class: DataSynchronizer{}

No Hooks.

Return

Array. Batch of records.

Usage

$DataSynchronizer = new DataSynchronizer();
$DataSynchronizer->get_next_batch_to_process( $size ): array;
$size(int) (required)
Size of the batch.

DataSynchronizer::get_next_batch_to_process() code WC 8.6.1

public function get_next_batch_to_process( int $size ): array {
	$orders_table_is_authoritative = $this->custom_orders_table_is_authoritative();

	$order_ids = $this->get_ids_of_orders_pending_sync(
		$orders_table_is_authoritative ? self::ID_TYPE_MISSING_IN_POSTS_TABLE : self::ID_TYPE_MISSING_IN_ORDERS_TABLE,
		$size
	);
	if ( count( $order_ids ) >= $size ) {
		return $order_ids;
	}

	$updated_order_ids = $this->get_ids_of_orders_pending_sync( self::ID_TYPE_DIFFERENT_UPDATE_DATE, $size - count( $order_ids ) );
	$order_ids         = array_merge( $order_ids, $updated_order_ids );
	if ( count( $order_ids ) >= $size ) {
		return $order_ids;
	}

	$deleted_order_ids = $this->get_ids_of_orders_pending_sync(
		$orders_table_is_authoritative ? self::ID_TYPE_DELETED_FROM_ORDERS_TABLE : self::ID_TYPE_DELETED_FROM_POSTS_TABLE,
		$size - count( $order_ids )
	);
	$order_ids         = array_merge( $order_ids, $deleted_order_ids );

	return array_map( 'absint', $order_ids );
}