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:
Emili Castells 2024-02-21 10:38:28 +01:00 committed by GitHub
commit 4c79915567
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 5 deletions

View file

@ -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 ] );
}

View file

@ -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 ) {