Automattic\WooCommerce\Internal\DataStores\Orders
DataSynchronizer::get_next_batch_to_process
Returns the batch with records that needs to be processed for a given size.
Method of the class: DataSynchronizer{}
No Hooks.
Returns
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() DataSynchronizer::get next batch to process code WC 10.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 );
}