From a4bccbbb120a11e81caa500388432667cbf85c75 Mon Sep 17 00:00:00 2001 From: Emili Castells Guasch Date: Fri, 23 Feb 2024 11:59:13 +0100 Subject: [PATCH] Display subscription mode option name instead of value in status report --- modules/ppcp-status-report/src/StatusReportModule.php | 4 +++- modules/ppcp-wc-gateway/services.php | 11 ++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/modules/ppcp-status-report/src/StatusReportModule.php b/modules/ppcp-status-report/src/StatusReportModule.php index f26412778..a7e810abe 100644 --- a/modules/ppcp-status-report/src/StatusReportModule.php +++ b/modules/ppcp-status-report/src/StatusReportModule.php @@ -78,6 +78,8 @@ class StatusReportModule implements ModuleInterface { $had_ppec_plugin = PPECHelper::is_plugin_configured(); + $subscription_mode_options = $c->get( 'wcgateway.settings.fields.subscriptions_mode_options' ); + $items = array( array( 'label' => esc_html__( 'Onboarded', 'woocommerce-paypal-payments' ), @@ -169,7 +171,7 @@ class StatusReportModule implements ModuleInterface { 'description' => esc_html__( 'Whether subscriptions are active and their mode.', 'woocommerce-paypal-payments' ), 'value' => $this->subscriptions_mode_text( $subscription_helper->plugin_is_active(), - $settings->has( 'subscriptions_mode' ) ? (string) $settings->get( 'subscriptions_mode' ) : '', + $settings->has( 'subscriptions_mode' ) ? (string) $subscription_mode_options[ $settings->get( 'subscriptions_mode' ) ] : '', $subscriptions_mode_settings ), ), diff --git a/modules/ppcp-wc-gateway/services.php b/modules/ppcp-wc-gateway/services.php index 1af10b4ed..264cf3c1f 100644 --- a/modules/ppcp-wc-gateway/services.php +++ b/modules/ppcp-wc-gateway/services.php @@ -404,7 +404,6 @@ return array( 'wcgateway.admin.fees-renderer' => static function ( ContainerInterface $container ): FeesRenderer { return new FeesRenderer(); }, - 'wcgateway.settings.should-render-settings' => static function ( ContainerInterface $container ): bool { $sections = array( @@ -419,13 +418,15 @@ return array( return array_key_exists( $current_page_id, $sections ); }, - - 'wcgateway.settings.fields.subscriptions_mode' => static function ( ContainerInterface $container ): array { - $subscription_mode_options = array( + 'wcgateway.settings.fields.subscriptions_mode_options' => static function ( ContainerInterface $container ): array { + return array( 'vaulting_api' => __( 'PayPal Vaulting', 'woocommerce-paypal-payments' ), 'subscriptions_api' => __( 'PayPal Subscriptions', 'woocommerce-paypal-payments' ), 'disable_paypal_subscriptions' => __( 'Disable PayPal for subscriptions', 'woocommerce-paypal-payments' ), ); + }, + 'wcgateway.settings.fields.subscriptions_mode' => static function ( ContainerInterface $container ): array { + $subscription_mode_options = $container->get( 'wcgateway.settings.fields.subscriptions_mode_options' ); $billing_agreements_endpoint = $container->get( 'api.endpoint.billing-agreements' ); $reference_transaction_enabled = $billing_agreements_endpoint->reference_transaction_enabled(); @@ -440,7 +441,7 @@ return array( 'input_class' => array( 'wc-enhanced-select' ), 'desc_tip' => true, 'description' => __( 'Utilize PayPal Vaulting for flexible subscription processing with saved payment methods, create “PayPal Subscriptions” to bill customers at regular intervals, or disable PayPal for subscription-type products.', 'woocommerce-paypal-payments' ), - 'default' => 'vaulting_api', + 'default' => array_key_first( $subscription_mode_options ), 'options' => $subscription_mode_options, 'screens' => array( State::STATE_ONBOARDED,