From e70299e42b5ec76facbc3328c71133ad98ac8146 Mon Sep 17 00:00:00 2001 From: Alex P Date: Tue, 20 Jun 2023 10:30:15 +0300 Subject: [PATCH] Display funding source on the admin order page Now the payment method title on the admin order editing page includes the funding source instead of just "PayPal" the same as in the order list. --- .../src/Gateway/PayPalGateway.php | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/modules/ppcp-wc-gateway/src/Gateway/PayPalGateway.php b/modules/ppcp-wc-gateway/src/Gateway/PayPalGateway.php index 0a5835c31..c089ce00e 100644 --- a/modules/ppcp-wc-gateway/src/Gateway/PayPalGateway.php +++ b/modules/ppcp-wc-gateway/src/Gateway/PayPalGateway.php @@ -271,6 +271,27 @@ class PayPalGateway extends \WC_Payment_Gateway { $this->order_endpoint = $order_endpoint; } + /** + * Return the gateway's title. + * + * @return string + */ + public function get_title() { + if ( is_admin() ) { + // $theorder and other things for retrieving the order or post info are not available + // in the constructor, so must do it here. + global $theorder; + if ( $theorder instanceof WC_Order ) { + $payment_method_title = $theorder->get_payment_method_title(); + if ( $payment_method_title ) { + $this->title = $payment_method_title; + } + } + } + + return parent::get_title(); + } + /** * Whether the Gateway needs to be setup. *