Refactor ACDC title duplication

This commit is contained in:
Alex P 2023-10-06 09:52:24 +03:00
parent 7df1b04a4f
commit 65f60728c7
No known key found for this signature in database
GPG key ID: 54487A734A204D71
2 changed files with 21 additions and 6 deletions

View file

@ -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;
},

View file

@ -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'