mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Refactor button and paylater messaging default locations.
This commit is contained in:
parent
e7e5f10f83
commit
40bd3f1d5c
3 changed files with 43 additions and 12 deletions
|
@ -209,7 +209,9 @@ return array(
|
|||
static function ( ContainerInterface $container ): Settings {
|
||||
return new Settings(
|
||||
$container->get( 'wcgateway.button.default-locations' ),
|
||||
$container->get( 'wcgateway.settings.dcc-gateway-title.default' )
|
||||
$container->get( 'wcgateway.settings.dcc-gateway-title.default' ),
|
||||
$container->get( 'wcgateway.settings.pay-later.default-button-locations' ),
|
||||
$container->get( 'wcgateway.settings.pay-later.default-messaging-locations' )
|
||||
);
|
||||
}
|
||||
),
|
||||
|
@ -1360,6 +1362,11 @@ return array(
|
|||
'mini-cart' => 'Mini Cart',
|
||||
);
|
||||
},
|
||||
'wcgateway.button.default-locations' => static function( ContainerInterface $container ): array {
|
||||
$button_locations = $container->get( 'wcgateway.button.locations' );
|
||||
unset( $button_locations['mini-cart'] );
|
||||
return array_keys( $button_locations );
|
||||
},
|
||||
'wcgateway.settings.pay-later.messaging-locations' => static function( ContainerInterface $container ): array {
|
||||
$button_locations = $container->get( 'wcgateway.button.locations' );
|
||||
unset( $button_locations['mini-cart'] );
|
||||
|
@ -1371,10 +1378,8 @@ return array(
|
|||
)
|
||||
);
|
||||
},
|
||||
'wcgateway.button.default-locations' => static function( ContainerInterface $container ): array {
|
||||
$button_locations = $container->get( 'wcgateway.button.locations' );
|
||||
unset( $button_locations['mini-cart'] );
|
||||
return array_keys( $button_locations );
|
||||
'wcgateway.settings.pay-later.default-messaging-locations' => static function( ContainerInterface $container ): array {
|
||||
return array_keys( $container->get( 'wcgateway.settings.pay-later.messaging-locations' ) );
|
||||
},
|
||||
'wcgateway.settings.pay-later.button-locations' => static function( ContainerInterface $container ): array {
|
||||
$settings = $container->get( 'wcgateway.settings' );
|
||||
|
@ -1386,6 +1391,9 @@ return array(
|
|||
|
||||
return array_intersect_key( $button_locations, array_flip( $smart_button_selected_locations ) );
|
||||
},
|
||||
'wcgateway.settings.pay-later.default-button-locations' => static function( ContainerInterface $container ): array {
|
||||
return $container->get( 'wcgateway.button.default-locations' );
|
||||
},
|
||||
'wcgateway.ppcp-gateways' => static function ( ContainerInterface $container ): array {
|
||||
return array(
|
||||
PayPalGateway::ID,
|
||||
|
|
|
@ -73,7 +73,7 @@ return function ( ContainerInterface $container, array $fields ): array {
|
|||
'type' => 'ppcp-multiselect',
|
||||
'class' => array(),
|
||||
'input_class' => array( 'wc-enhanced-select' ),
|
||||
'default' => $container->get( 'wcgateway.button.default-locations' ),
|
||||
'default' => $container->get( 'wcgateway.settings.pay-later.default-button-locations' ),
|
||||
'desc_tip' => false,
|
||||
'description' => __( 'Select where the Pay Later button should be displayed.', 'woocommerce-paypal-payments' ),
|
||||
'options' => $container->get( 'wcgateway.settings.pay-later.button-locations' ),
|
||||
|
@ -119,7 +119,7 @@ return function ( ContainerInterface $container, array $fields ): array {
|
|||
'type' => 'ppcp-multiselect',
|
||||
'class' => array(),
|
||||
'input_class' => array( 'wc-enhanced-select' ),
|
||||
'default' => $container->get( 'wcgateway.button.default-locations' ),
|
||||
'default' => $container->get( 'wcgateway.settings.pay-later.default-messaging-locations' ),
|
||||
'desc_tip' => false,
|
||||
'description' => __( 'Select where the Pay Later messaging should be displayed.', 'woocommerce-paypal-payments' ),
|
||||
'options' => $container->get( 'wcgateway.settings.pay-later.messaging-locations' ),
|
||||
|
|
|
@ -35,6 +35,20 @@ class Settings implements ContainerInterface {
|
|||
*/
|
||||
protected $default_button_locations;
|
||||
|
||||
/**
|
||||
* The list of selected default pay later button locations.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $default_pay_later_button_locations;
|
||||
|
||||
/**
|
||||
* The list of selected default pay later messaging locations.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $default_pay_later_messaging_locations;
|
||||
|
||||
/**
|
||||
* The default ACDC gateway title.
|
||||
*
|
||||
|
@ -47,10 +61,19 @@ class Settings implements ContainerInterface {
|
|||
*
|
||||
* @param string[] $default_button_locations The list of selected default button locations.
|
||||
* @param string $default_dcc_gateway_title The default ACDC gateway title.
|
||||
* @param string[] $default_pay_later_button_locations The list of selected default pay later button locations.
|
||||
* @param string[] $default_pay_later_messaging_locations The list of selected default pay later messaging locations.
|
||||
*/
|
||||
public function __construct( array $default_button_locations, string $default_dcc_gateway_title ) {
|
||||
public function __construct(
|
||||
array $default_button_locations,
|
||||
string $default_dcc_gateway_title,
|
||||
array $default_pay_later_button_locations,
|
||||
array $default_pay_later_messaging_locations
|
||||
) {
|
||||
$this->default_button_locations = $default_button_locations;
|
||||
$this->default_dcc_gateway_title = $default_dcc_gateway_title;
|
||||
$this->default_pay_later_button_locations = $default_pay_later_button_locations;
|
||||
$this->default_pay_later_messaging_locations = $default_pay_later_messaging_locations;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -122,8 +145,8 @@ class Settings implements ContainerInterface {
|
|||
'smart_button_enable_styling_per_location' => true,
|
||||
'pay_later_messaging_enabled' => true,
|
||||
'pay_later_button_enabled' => true,
|
||||
'pay_later_button_locations' => $this->default_button_locations,
|
||||
'pay_later_messaging_locations' => $this->default_button_locations,
|
||||
'pay_later_button_locations' => $this->default_pay_later_button_locations,
|
||||
'pay_later_messaging_locations' => $this->default_pay_later_messaging_locations,
|
||||
'brand_name' => get_bloginfo( 'name' ),
|
||||
'dcc_gateway_title' => $this->default_dcc_gateway_title,
|
||||
'dcc_gateway_description' => __(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue