mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
Merge pull request #2042 from woocommerce/PCP-2672-disable-pay-later-messaging-configurator-when-pay-pal-vaulting-is-enabled
Disable messaging configurator when vault is enabled (2672)
This commit is contained in:
commit
4c79915567
2 changed files with 16 additions and 5 deletions
|
@ -10,6 +10,7 @@ declare(strict_types=1);
|
|||
namespace WooCommerce\PayPalCommerce\PayLaterConfigurator;
|
||||
|
||||
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
||||
|
||||
return array(
|
||||
'wcgateway.settings.fields' => function ( ContainerInterface $container, array $fields ): array {
|
||||
|
@ -63,8 +64,16 @@ return array(
|
|||
'pay_later_home_message_flex_color',
|
||||
'pay_later_home_message_flex_ratio',
|
||||
'pay_later_home_message_preview',
|
||||
'pay_later_messaging_enabled',
|
||||
);
|
||||
|
||||
$settings = $container->get( 'wcgateway.settings' );
|
||||
assert( $settings instanceof Settings );
|
||||
$vault_enabled = $settings->has( 'vault_enabled' ) && $settings->get( 'vault_enabled' );
|
||||
|
||||
if ( ! $vault_enabled ) {
|
||||
$old_fields[] = 'pay_later_messaging_enabled';
|
||||
}
|
||||
|
||||
foreach ( $old_fields as $old_field ) {
|
||||
unset( $fields[ $old_field ] );
|
||||
}
|
||||
|
|
|
@ -50,7 +50,12 @@ class PayLaterConfiguratorModule implements ModuleInterface {
|
|||
$messages_apply = $c->get( 'button.helper.messages-apply' );
|
||||
assert( $messages_apply instanceof MessagesApply );
|
||||
|
||||
if ( ! $messages_apply->for_country() ) {
|
||||
$settings = $c->get( 'wcgateway.settings' );
|
||||
assert( $settings instanceof Settings );
|
||||
|
||||
$vault_enabled = $settings->has( 'vault_enabled' ) && $settings->get( 'vault_enabled' );
|
||||
|
||||
if ( $vault_enabled || ! $messages_apply->for_country() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -69,9 +74,6 @@ class PayLaterConfiguratorModule implements ModuleInterface {
|
|||
return;
|
||||
}
|
||||
|
||||
$settings = $c->get( 'wcgateway.settings' );
|
||||
assert( $settings instanceof Settings );
|
||||
|
||||
add_action(
|
||||
'init',
|
||||
static function () use ( $c, $settings ) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue