You can try to add the below code in your theme’s functions.php file.
function th37t_display_conditional_payment_gateways($_available_gateways){
$field_value = th34y_get_posted_value('your_field_name');
if(is_array($_available_gateways) && $field_value === 'your_field_value'){
unset($_available_gateways['direct-debit']);
unset($_available_gateways['cheque']);
}
return $_available_gateways;
}
add_filter('woocommerce_available_payment_gateways', 'th37t_display_conditional_payment_gateways');
function th34y_get_posted_value($key){
$value = isset($_POST[$key]) ? stripslashes($_POST[$key]) : '';
if(!$value){
$post_data = isset($_POST['post_data']) ? $_POST['post_data'] : '';
if($post_data){
parse_str($post_data, $post_data_arr);
$value = isset($post_data_arr[$key]) ? stripslashes($post_data_arr[$key]) : '';
}
}
return $value;
}
Please note that you need to replace your_field_name and your_field_value with the field and value that you have provided on your site.
Also, please add the class update_totals_on_change for the field.
We hope this will help.
Thank you!