From f8ed3328a80904b7459a565881fe595a632f1c32 Mon Sep 17 00:00:00 2001 From: Emili Castells Guasch Date: Mon, 15 Jul 2024 15:56:35 +0200 Subject: [PATCH] Dispaly googlepay payment method only if googlepay button is enabled --- modules/ppcp-googlepay/src/GooglepayModule.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/ppcp-googlepay/src/GooglepayModule.php b/modules/ppcp-googlepay/src/GooglepayModule.php index ee989a019..8167e87f9 100644 --- a/modules/ppcp-googlepay/src/GooglepayModule.php +++ b/modules/ppcp-googlepay/src/GooglepayModule.php @@ -173,10 +173,15 @@ class GooglepayModule implements ModuleInterface { return $methods; } - $googlepay_gateway = $c->get( 'googlepay.wc-gateway' ); - assert( $googlepay_gateway instanceof WC_Payment_Gateway ); + $settings = $c->get( 'wcgateway.settings' ); + assert( $settings instanceof Settings ); - $methods[] = $googlepay_gateway; + if ( $settings->has( 'googlepay_button_enabled' ) && $settings->get( 'googlepay_button_enabled' ) ) { + $googlepay_gateway = $c->get( 'googlepay.wc-gateway' ); + assert( $googlepay_gateway instanceof WC_Payment_Gateway ); + + $methods[] = $googlepay_gateway; + } return $methods; }