We already shared code with you which is expired
Here it is add this to your customizer plugin:
add_action( 'woocommerce_before_cart_table', 'custom_add_to_cart_redirect' );
function custom_add_to_cart_redirect() {
$current_user_id = get_current_user_id();
if(class_exists('WPLMS_Batch_Functions')){
$wplms_batches = WPLMS_Batch_Functions::init();
$batch_ids=$wplms_batches->get_user_batches($current_user_id);
if(!empty($batch_ids) && count($batch_ids)){
global $woocommerce;
$woocommerce->cart->empty_cart();
$message = __('You can not enroll in multiple batches','wplms-batches');
wc_print_notice($message,'error');
}
}
}