Automattic\WooCommerce\Internal\Logging
OrderLogsDeletionProcessor::process_batch
Process a batch of items. Items are expected to be in the format returned by get_next_batch_to_process.
Method of the class: OrderLogsDeletionProcessor{}
No Hooks.
Returns
null. Nothing (null).
Usage
$OrderLogsDeletionProcessor = new OrderLogsDeletionProcessor(); $OrderLogsDeletionProcessor->process_batch( $batch ): void;
- $batch(array) (required)
- Batch of items to process.
OrderLogsDeletionProcessor::process_batch() OrderLogsDeletionProcessor::process batch code WC 10.8.1
public function process_batch( array $batch ): void {
if ( empty( $batch ) ) {
return;
}
if ( ! $this->hpos_in_use && ! $this->cpt_in_use ) {
$this->throw_doing_it_wrong( StringUtil::class_name_without_namespace( __CLASS__ ) . '::' . __FUNCTION__ );
return;
}
$items = array();
foreach ( $batch as $item ) {
if ( ! is_array( $item ) || ! isset( $item['meta_value'] ) || ! isset( $item['order_id'] ) ) {
throw new \Exception( "\$batch must be an array of arrays, each having a 'meta_value' key and an 'order_id' key" );
}
$items[ $item['order_id'] ] = $item['meta_value'];
}
$this->order_logs_cleanup_helper->clear_logs_and_delete_meta( $items );
}