mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-30 05:00:51 +08:00
Refactor event listener setup for place order button
This commit is contained in:
parent
b8e85fe3f2
commit
c1dbb83350
1 changed files with 4 additions and 5 deletions
|
@ -82,9 +82,8 @@ import {
|
|||
renderFields( cardFields );
|
||||
}
|
||||
|
||||
document
|
||||
.querySelector( '#place_order' )
|
||||
?.addEventListener( 'click', ( event ) => {
|
||||
const placeOrderButton = document.querySelector( '#place_order' );
|
||||
placeOrderButton?.addEventListener( 'click', ( event ) => {
|
||||
const cardPaymentToken = document.querySelector(
|
||||
'input[name="wc-ppcp-credit-card-gateway-payment-token"]:checked'
|
||||
)?.value;
|
||||
|
@ -95,11 +94,11 @@ import {
|
|||
) {
|
||||
return;
|
||||
}
|
||||
document.getElementById('place_order').disabled = true;
|
||||
placeOrderButton.disabled = true;
|
||||
event.preventDefault();
|
||||
cardFields.submit().catch( ( error ) => {
|
||||
console.error( error );
|
||||
document.getElementById('place_order').disabled = false;
|
||||
placeOrderButton.disabled = false;
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue