Automattic\WooCommerce\Internal

OrderCouponDataMigrator::process_batchpublicWC 1.0

Process data for the supplied batch. See the convert_item method.

Method of the class: OrderCouponDataMigrator{}

No Hooks.

Returns

null. Nothing (null).

Usage

$OrderCouponDataMigrator = new OrderCouponDataMigrator();
$OrderCouponDataMigrator->process_batch( $batch ): void;
$batch(array) (required)
Batch to process, as returned by 'get_next_batch_to_process'.

OrderCouponDataMigrator::process_batch() code WC 9.9.5

public function process_batch( array $batch ): void {
	global $wpdb;

	if ( empty( $batch ) ) {
		return;
	}

	$meta_ids = StringUtil::to_sql_list( $batch );

	$meta_ids_and_values = $wpdb->get_results(
		//phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
		"SELECT meta_id,meta_value FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE meta_id IN $meta_ids",
		ARRAY_N
	);

	foreach ( $meta_ids_and_values as $meta_id_and_value ) {
		try {
			$this->convert_item( (int) $meta_id_and_value[0], $meta_id_and_value[1] );
		} catch ( Exception $ex ) {
			wc_get_logger()->error( StringUtil::class_name_without_namespace( self::class ) . ": when converting meta row with id {$meta_id_and_value[0]}: {$ex->getMessage()}" );
		}
	}
}