mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-04 08:47:23 +08:00
🐛 Fix incorrect display of initial button
Logic to hide the payment button when used as a smart-button (not as a separate gateway) had a bug, if the PayPal method was not the first payment gateway. The new logic ensures that the payment button’s visibility is correct, regardless on whether it’s a separate payment gateway or included in the PayPal smart-button block.
This commit is contained in:
parent
8c1a6f72dc
commit
b7d18f105e
1 changed files with 9 additions and 6 deletions
|
@ -461,16 +461,19 @@ export default class PaymentButton {
|
|||
* @return {boolean} True means that this payment method is selected as current gateway.
|
||||
*/
|
||||
get isCurrentGateway() {
|
||||
if ( ! this.isSeparateGateway ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* We need to rely on `getCurrentPaymentMethod()` here, as the `CheckoutBootstrap.js`
|
||||
* module fires the "ButtonEvents.RENDER" event before any PaymentButton instances are
|
||||
* created. I.e. we cannot observe the initial gateway selection event.
|
||||
*/
|
||||
return this.methodId === getCurrentPaymentMethod();
|
||||
const currentMethod = getCurrentPaymentMethod();
|
||||
|
||||
if ( this.isSeparateGateway ) {
|
||||
return this.methodId === currentMethod;
|
||||
}
|
||||
|
||||
// Button is rendered inside the Smart Buttons block.
|
||||
return PaymentMethods.PAYPAL === currentMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -703,7 +706,7 @@ export default class PaymentButton {
|
|||
|
||||
this.applyWrapperStyles();
|
||||
|
||||
if ( this.isEligible && this.isPresent && this.isVisible ) {
|
||||
if ( this.isEligible && this.isCurrentGateway && this.isVisible ) {
|
||||
if ( ! this.isButtonAttached ) {
|
||||
this.log( 'refresh.addButton' );
|
||||
this.addButton();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue