Thursday, 29 October 2020

WooCommerce - Deselect Default Payment Method

I am trying to get WooCommerce to not automatically select the first payment method on the checkout page.

This would force the customer to select a payment method on their own and neaten up the checkout page. At present, with the first payment method automatically selected lots of payment information relating to that method is shown to the customer and pushes the other payment methods down the page. On mobile this is a problem as some think this is the only method of payment due to stacking.

The below JS works in removing a default payment method being selected.

However, when I try to then select a payment method, it initially loads the gateway information but then disappears and the selection is removed. I suspect AJAX is causing an issue here due to how this section reloads. This makes it impossible to select a payment method.

Could anyone help expand on this code to allow a gateway selection ? Many Thanks

jQuery(document).ready(function( $ ){
    $( document ).on( 'updated_checkout', function() {
        var $paymentCheckboxes = $( ".woocommerce-checkout-payment" ).find( '[name="payment_method"]');
        $paymentCheckboxes.attr('checked', false);
        $('.payment_box').hide();
    });
});

Payment methods are all unselected, allowing a customer to see which methods are available better.



from WooCommerce - Deselect Default Payment Method

No comments:

Post a Comment