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.

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

Хуков нет.

Возвращает

Массив. Batch of records.

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

$DataSynchronizer = new DataSynchronizer();
$DataSynchronizer->get_next_batch_to_process( $size ): array;
$size(int) (обязательный)
Size of the batch.

Код DataSynchronizer::get_next_batch_to_process() WC 8.7.0

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 );
}