From 48f9efbfd4bfcc22488fef7e191102773cda0b43 Mon Sep 17 00:00:00 2001
From: Pedro Silva
Date: Tue, 2 Apr 2024 11:19:00 +0100
Subject: [PATCH] Fix display of paypal email when funding source is not
paypal.
---
modules/ppcp-wc-gateway/src/WCGatewayModule.php | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/modules/ppcp-wc-gateway/src/WCGatewayModule.php b/modules/ppcp-wc-gateway/src/WCGatewayModule.php
index d0e57e5de..4295b1b17 100644
--- a/modules/ppcp-wc-gateway/src/WCGatewayModule.php
+++ b/modules/ppcp-wc-gateway/src/WCGatewayModule.php
@@ -473,6 +473,14 @@ class WCGatewayModule implements ModuleInterface {
return $fields;
}
+ // Is payment source is paypal exclude all non paypal funding sources.
+ $payment_source = $theorder->get_meta( PayPalGateway::ORDER_PAYMENT_SOURCE_META_KEY ) ?: '';
+ $is_paypal_funding_source = ( strpos( $theorder->get_payment_method_title(), '(via PayPal)' ) === false );
+
+ if ( $payment_source === 'paypal' && ! $is_paypal_funding_source ) {
+ return $fields;
+ }
+
$fields['paypal_email'] = array(
'label' => __( 'PayPal email address', 'woocommerce-paypal-payments' ),
'value' => $email,