From 65f60728c77ed5493430ebbf64fba82a40d82143 Mon Sep 17 00:00:00 2001 From: Alex P Date: Fri, 6 Oct 2023 09:52:24 +0300 Subject: [PATCH] Refactor ACDC title duplication --- modules/ppcp-wc-gateway/services.php | 12 +++++++++--- modules/ppcp-wc-gateway/src/Settings/Settings.php | 15 ++++++++++++--- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/modules/ppcp-wc-gateway/services.php b/modules/ppcp-wc-gateway/services.php index 23223d3c6..cba701931 100644 --- a/modules/ppcp-wc-gateway/services.php +++ b/modules/ppcp-wc-gateway/services.php @@ -201,8 +201,10 @@ return array( }, 'wcgateway.settings' => static function ( ContainerInterface $container ): Settings { - $default_button_locations = $container->get( 'wcgateway.button.default-locations' ); - return new Settings( $default_button_locations ); + return new Settings( + $container->get( 'wcgateway.button.default-locations' ), + $container->get( 'wcgateway.settings.dcc-gateway-title.default' ) + ); }, 'wcgateway.notice.connect' => static function ( ContainerInterface $container ): ConnectAdminNotice { $state = $container->get( 'onboarding.state' ); @@ -487,7 +489,7 @@ return array( 'This controls the title which the user sees during checkout.', 'woocommerce-paypal-payments' ), - 'default' => __( 'Debit & Credit Cards', 'woocommerce-paypal-payments' ), + 'default' => $container->get( 'wcgateway.settings.dcc-gateway-title.default' ), 'desc_tip' => true, 'screens' => array( State::STATE_ONBOARDED, @@ -1186,6 +1188,10 @@ return array( return $vaulting_label; }, + 'wcgateway.settings.dcc-gateway-title.default' => static function ( ContainerInterface $container ): string { + return __( 'Debit & Credit Cards', 'woocommerce-paypal-payments' ); + }, + 'wcgateway.settings.card_billing_data_mode.default' => static function ( ContainerInterface $container ): string { return $container->get( 'api.shop.is-latin-america' ) ? CardBillingMode::MINIMAL_INPUT : CardBillingMode::USE_WC; }, diff --git a/modules/ppcp-wc-gateway/src/Settings/Settings.php b/modules/ppcp-wc-gateway/src/Settings/Settings.php index 1eca02587..9abca804d 100644 --- a/modules/ppcp-wc-gateway/src/Settings/Settings.php +++ b/modules/ppcp-wc-gateway/src/Settings/Settings.php @@ -35,13 +35,22 @@ class Settings implements ContainerInterface { */ protected $default_button_locations; + /** + * The default ACDC gateway title. + * + * @var string + */ + protected $default_dcc_gateway_title; + /** * Settings constructor. * * @param string[] $default_button_locations The list of selected default button locations. + * @param string $default_dcc_gateway_title The default ACDC gateway title. */ - public function __construct( array $default_button_locations ) { - $this->default_button_locations = $default_button_locations; + public function __construct( array $default_button_locations, string $default_dcc_gateway_title ) { + $this->default_button_locations = $default_button_locations; + $this->default_dcc_gateway_title = $default_dcc_gateway_title; } /** @@ -116,7 +125,7 @@ class Settings implements ContainerInterface { 'pay_later_button_locations' => $this->default_button_locations, 'pay_later_messaging_locations' => $this->default_button_locations, 'brand_name' => get_bloginfo( 'name' ), - 'dcc_gateway_title' => __( 'Debit & Credit Cards', 'woocommerce-paypal-payments' ), + 'dcc_gateway_title' => $this->default_dcc_gateway_title, 'dcc_gateway_description' => __( 'Pay with your credit card.', 'woocommerce-paypal-payments'