Solution:
/* if you want the title of the payment method */
add_action( 'woocommerce_review_order_before_payment', 'ts_refresh_payment_method' );
function ts_refresh_payment_method(){
$chosen_payment_method = WC()->session->get('chosen_payment_method'); //Get the selected payment method
// jQuery
?>
<script type="text/javascript">
(function($){
var cpm = '<?php echo $chosen_payment_method; ?>';
if(cpm == "paypal"){
$(".woocommerce-billing-fields").hide();
}else{
$(".woocommerce-billing-fields").show();
}
$( 'form.checkout' ).on( 'change', 'input[name^="payment_method"]', function() {
//alert(this.value);
if(this.value == "paypal"){
$(".woocommerce-billing-fields").hide();
}else{
$(".woocommerce-billing-fields").show();
}
$('body').trigger('update_checkout');
});
alert($('body').trigger('update_checkout'));
})(jQuery);
</script>
<?php
}
/* */
add_filter('woocommerce_billing_fields','wpb_custom_billing_fields');
function wpb_custom_billing_fields( $fields = array() ) {
$chosen_payment_method = WC()->session->get('chosen_payment_method');
if($chosen_payment_method == "paypal"){
$fields['billing_first_name']['required']= false;
$fields['billing_last_name']['required']= false;
$fields['billing_company']['required'] = false;
$fields['billing_email']['required'] = false;
$fields['billing_address_1']['required']= false;
$fields['billing_address_2']['required']= false;
$fields['billing_state']['required'] = false;
$fields['billing_city']['required'] = false;
$fields['billing_phone']['required'] = false;
$fields['billing_postcode']['required'] = false;
$fields['billing_country']['required'] = false;
}
return $fields;
}