Extract currentPaymentMethod

This commit is contained in:
Alex P 2021-11-10 16:27:00 +02:00
parent 51517f1196
commit 9624c85a6c

View file

@ -67,8 +67,7 @@ class CheckoutBootstap {
switchBetweenPayPalandOrderButton() { switchBetweenPayPalandOrderButton() {
jQuery('#saved-credit-card').val(jQuery('#saved-credit-card option:first').val()); jQuery('#saved-credit-card').val(jQuery('#saved-credit-card option:first').val());
const currentPaymentMethod = jQuery( const currentPaymentMethod = this.currentPaymentMethod();
'input[name="payment_method"]:checked').val();
if (currentPaymentMethod !== 'ppcp-gateway' && currentPaymentMethod !== 'ppcp-credit-card-gateway') { if (currentPaymentMethod !== 'ppcp-gateway' && currentPaymentMethod !== 'ppcp-credit-card-gateway') {
this.renderer.hideButtons(this.gateway.button.wrapper); this.renderer.hideButtons(this.gateway.button.wrapper);
@ -93,8 +92,7 @@ class CheckoutBootstap {
} }
displayPlaceOrderButtonForSavedCreditCards() { displayPlaceOrderButtonForSavedCreditCards() {
const currentPaymentMethod = jQuery( const currentPaymentMethod = this.currentPaymentMethod();
'input[name="payment_method"]:checked').val();
if (currentPaymentMethod !== 'ppcp-credit-card-gateway') { if (currentPaymentMethod !== 'ppcp-credit-card-gateway') {
return; return;
} }
@ -139,6 +137,10 @@ class CheckoutBootstap {
jQuery('#ppcp-credit-card-vault').attr("disabled", false) jQuery('#ppcp-credit-card-vault').attr("disabled", false)
this.renderer.enableCreditCardFields() this.renderer.enableCreditCardFields()
} }
currentPaymentMethod() {
return jQuery('input[name="payment_method"]:checked').val();
}
} }
export default CheckoutBootstap export default CheckoutBootstap