On Checkout page payment methods are presented and the first one is selected by default and automatically. I need to prevent the selection so no payment method is initially selected by WC.
I tried 2 things so far:
jQuery from Chrome console:
jQuery( '.payment_methods input.input-radio' ).prop('checked', false);
result:
[<input id="payment_method_paypal" type="radio" class="input-radio" name="payment_method" value="paypal" data-order_button_text="Proceed to PayPal" checked="checked">,
<input id="payment_method_accountfunds" type="radio" class="input-radio" name="payment_method" value="accountfunds" data-order_button_text>]
Remove the code from payment-method.php Woocommerce template file:
checked( $gateway->chosen, false );
Neither is working. How to do it? Any snippet or suggestion for that, please?
EDIT:
Also tried this:
function wpchris_filter_gateways( $gateways ){
global $woocommerce;
foreach ($gateways as $gateway) {
$gateway->chosen = 0;
}
return $gateways;
}
add_filter( 'woocommerce_available_payment_gateways', 'wpchris_filter_gateways', 1);