Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins
Days
Hours
Minutes
Seconds

How to Remove the Default Pre-selected Payment Method on the WooCommerce Checkout Page?

Different customers may have different preferences or requirements when it comes to payment methods. Some might prefer credit cards, while others may prefer digital wallets or bank transfers. This customization is very useful in removing the default preselected payment option and providing customers with the flexibility to choose their preferred payment method.

add_action('woocommerce_before_checkout_form', 'ts_uncheck_default_payment_gateway');

function ts_uncheck_default_payment_gateway() {
    wc_enqueue_js("
        // Function to uncheck payment methods and hide payment boxes
        function uncheckPaymentMethods() {
            // ONLY RUN IF MORE THAN 1 PAYMENT OPTION
            if ($('.woocommerce-checkout').find('input[name=\"payment_method\"]').length === 1) return;

            // UNCHECK CHECKED PAYMENT METHOD
            $('input[name=\"payment_method\"]').prop('checked', false);

            // CLOSE CHECKED PAYMENT DESCRIPTION BOX
            $('div.payment_box').hide();
        }

        // Run the function on document ready
        $(document).ready(function() {
            uncheckPaymentMethods();
        });

        // Run the function on updated_checkout event but only once
        $(document.body).one('updated_checkout', function() {
            uncheckPaymentMethods();
        });
    ");
}

Output

The output shows that the default pre-selected payment method is removed and all the payment options are set to be unchecked on the WooCommerce checkout page. Additionally, the description gets hidden and when the user selects any payment method, then it is shown.

How to Remove the Default Pre-selected Payment Method on the WooCommerce Checkout Page? - Tyche Softwares

The following output shows the default preselected payment method that appears in the absence of implementing the above code.

How to Remove the Default Pre-selected Payment Method on the WooCommerce Checkout Page? - Tyche Softwares

Similarly, you can also remove the default pre-selected shipping method on the WooCommerce checkout page.

Browse more in: Code Snippets, WooCommerce How Tos, WooCommerce Tutorials

Share It:

Subscribe
Notify of
4 Comments
Newest
Oldest
Inline Feedbacks
View all comments
Youssef
3 months ago

Hello, when we activate your snippet and select a payment method it is automatically unchecked, i saw someone else complained about this but you didn’t fix it yet.

Lady
3 months ago

Hi thanks for this code snippet, I tell you that when I activate it and select a payment method it is automatically unchecked, could you please help me?

4
0
Would love your thoughts, please comment.x
()
x