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( "
 
      // ONLY RUN ON CHECKOUT PAGE LOAD
      $( document.body ).on( 'updated_checkout', function() {
          
         // ONLY RUN IF MORE THAN 1 PAYMENT OPTION
         if ( $( '.woocommerce-checkout' ).find( 'input[name=\'payment_method\']' ).length === 1 ) return false;
 
         // UNCHECK CHECKED PAYMENT METHOD
         $('input[name=\'payment_method\']').prop('checked', false);
          
         // CLOSE CHECKED PAYMENT DESCRIPTION BOX
         $('div.payment_box').hide();
 
      });
   " );
}

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
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x