From b298dd619801063c50ab5a0601ceb959bd3834ad Mon Sep 17 00:00:00 2001 From: Mike Moore Date: Fri, 1 Nov 2024 13:53:51 -0400 Subject: [PATCH 1/2] Hide duplicate payment method warnings when Stripe gateway is disabled --- ...x-9271-hide-stripe-duplicates-warning-when-disabled | 5 +++++ includes/class-duplicates-detection-service.php | 10 +++------- 2 files changed, 8 insertions(+), 7 deletions(-) create mode 100644 changelog/fix-9271-hide-stripe-duplicates-warning-when-disabled diff --git a/changelog/fix-9271-hide-stripe-duplicates-warning-when-disabled b/changelog/fix-9271-hide-stripe-duplicates-warning-when-disabled new file mode 100644 index 00000000000..46e04c54622 --- /dev/null +++ b/changelog/fix-9271-hide-stripe-duplicates-warning-when-disabled @@ -0,0 +1,5 @@ +Significance: patch +Type: fix +Comment: Small change affecting Stripe Gateway settings notices + + diff --git a/includes/class-duplicates-detection-service.php b/includes/class-duplicates-detection-service.php index 420545e0ce8..ee4fe9176a5 100644 --- a/includes/class-duplicates-detection-service.php +++ b/includes/class-duplicates-detection-service.php @@ -78,6 +78,8 @@ private function search_for_cc() { $keywords = [ 'credit_card', 'creditcard', 'cc', 'card' ]; $special_keywords = [ 'woocommerce_payments', 'stripe' ]; + $gateways = $this->get_enabled_gateways(); + foreach ( $this->get_enabled_gateways() as $gateway ) { if ( $this->gateway_contains_keyword( $gateway->id, $keywords ) || in_array( $gateway->id, $special_keywords, true ) ) { $this->gateways_qualified_by_duplicates_detector[ CC_Payment_Method::PAYMENT_METHOD_STRIPE_ID ][] = $gateway->id; @@ -136,18 +138,12 @@ private function search_for_payment_request_buttons() { ]; foreach ( $this->get_registered_gateways() as $gateway ) { - // Stripe gateway can enable PRBs while being disabled as well, hence no need to check for enabled status. - if ( 'stripe' === $gateway->id && 'yes' === $gateway->get_option( 'payment_request' ) ) { - $this->gateways_qualified_by_duplicates_detector[ $prb_payment_method ][] = $gateway->id; - continue; - } - if ( 'yes' === $gateway->enabled ) { foreach ( $keywords as $keyword ) { if ( strpos( $gateway->id, $keyword ) !== false ) { $this->gateways_qualified_by_duplicates_detector[ $prb_payment_method ][] = $gateway->id; break; - } elseif ( 'yes' === $gateway->get_option( 'payment_request' ) && 'woocommerce_payments' === $gateway->id ) { + } elseif ( 'yes' === $gateway->get_option( 'payment_request' ) ) { $this->gateways_qualified_by_duplicates_detector[ $prb_payment_method ][] = $gateway->id; break; } elseif ( 'yes' === $gateway->get_option( 'express_checkout_enabled' ) ) { From b0a9d69a55dd0173d6c21c5ed3b2848c1ce69cb6 Mon Sep 17 00:00:00 2001 From: Mike Moore Date: Fri, 1 Nov 2024 17:01:35 -0400 Subject: [PATCH 2/2] Remove debug code --- includes/class-duplicates-detection-service.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/includes/class-duplicates-detection-service.php b/includes/class-duplicates-detection-service.php index ee4fe9176a5..c2ffe05385a 100644 --- a/includes/class-duplicates-detection-service.php +++ b/includes/class-duplicates-detection-service.php @@ -78,8 +78,6 @@ private function search_for_cc() { $keywords = [ 'credit_card', 'creditcard', 'cc', 'card' ]; $special_keywords = [ 'woocommerce_payments', 'stripe' ]; - $gateways = $this->get_enabled_gateways(); - foreach ( $this->get_enabled_gateways() as $gateway ) { if ( $this->gateway_contains_keyword( $gateway->id, $keywords ) || in_array( $gateway->id, $special_keywords, true ) ) { $this->gateways_qualified_by_duplicates_detector[ CC_Payment_Method::PAYMENT_METHOD_STRIPE_ID ][] = $gateway->id;