diff --git a/plugins/woocommerce/changelog/fix-invalid-payment-error-upon-double-click-delete b/plugins/woocommerce/changelog/fix-invalid-payment-error-upon-double-click-delete new file mode 100644 index 00000000000..64a2fd56147 --- /dev/null +++ b/plugins/woocommerce/changelog/fix-invalid-payment-error-upon-double-click-delete @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Fix 'Invalid payment method' error upon double click on Delete button of Payment methods table diff --git a/plugins/woocommerce/client/legacy/js/frontend/add-payment-method.js b/plugins/woocommerce/client/legacy/js/frontend/add-payment-method.js index b200c6921fe..1ccdefac3cb 100644 --- a/plugins/woocommerce/client/legacy/js/frontend/add-payment-method.js +++ b/plugins/woocommerce/client/legacy/js/frontend/add-payment-method.js @@ -32,4 +32,13 @@ jQuery( function( $ ) { $( document.body ).trigger( 'init_add_payment_method' ); + // Prevent firing multiple requests upon double clicking the buttons in payment methods table + $(' .woocommerce .payment-method-actions .button.delete' ).on( 'click' , function( event ) { + if ( $( this ).hasClass( 'disabled' ) ) { + event.preventDefault(); + } + + $( this ).addClass( 'disabled' ); + }); + });