Filter Uncanny Redemption Codes

ulc_cancel_codes_max_per_batch

Filters the maximum number of cancellation codes that can be processed in a single batch.

add_filter( 'ulc_cancel_codes_max_per_batch', $callback, 10, 1 );

Description

Filters the maximum number of cancel codes processed per batch during a bulk operation. Developers can use this hook to adjust the batch size, potentially improving performance or preventing memory limits for large imports. The default value is 2000.


Usage

add_filter( 'ulc_cancel_codes_max_per_batch', 'your_function_name', 10, 1 );

Return Value

The filtered value.


Examples

// Limit the maximum number of cancel codes processed in a single batch to 1500 instead of the default 2000.
function my_custom_cancel_codes_batch_limit( $max_batch_size ) {
    // Ensure the returned value is a positive integer.
    $new_limit = 1500;
    return absint( $new_limit );
}
add_filter( 'ulc_cancel_codes_max_per_batch', 'my_custom_cancel_codes_batch_limit', 10, 1 );

Placement

This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.


Source Code

src/classes/admin/class-cancel-codes.php:203

array(
									'code',
									'codes',
								),
								true
							)
						) {
							$max_rows_per_run = apply_filters( 'ulc_cancel_codes_max_per_batch', 2000 );
							$row              = 0;
							while ( ( $data = fgetcsv( $file, $max_rows_per_run, ',' ) ) !== false ) {
								$row ++;
							}
							fclose( $file );

							if ( absint( $row ) > $max_rows_per_run ) {

Scroll to Top