Skip to content

Commit 3b80ec8

Browse files
authored
Merge pull request #3609 from woocommerce/PCP-5189-create-banner-for-global-pay-later-messaging-enablement-in-legacy-settings-ui
Add Pay Later messaging enablement banner for legacy UI (5189)
2 parents 46eeeb0 + 7905fe2 commit 3b80ec8

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

modules/ppcp-settings/src/SettingsModule.php

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use WooCommerce\PayPalCommerce\Applepay\ApplePayGateway;
1919
use WooCommerce\PayPalCommerce\Applepay\Assets\AppleProductStatus;
2020
use WooCommerce\PayPalCommerce\Axo\Gateway\AxoGateway;
21+
use WooCommerce\PayPalCommerce\Button\Helper\MessagesApply;
2122
use WooCommerce\PayPalCommerce\Googlepay\GooglePayGateway;
2223
use WooCommerce\PayPalCommerce\Googlepay\Helper\ApmProductStatus;
2324
use WooCommerce\PayPalCommerce\LocalAlternativePaymentMethods\BancontactGateway;
@@ -55,6 +56,7 @@
5556
use WooCommerce\PayPalCommerce\Settings\Data\GeneralSettings;
5657
use WooCommerce\PayPalCommerce\Settings\Data\PaymentSettings;
5758
use WooCommerce\PayPalCommerce\Axo\Helper\CompatibilityChecker;
59+
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
5860

5961
/**
6062
* Class SettingsModule
@@ -113,7 +115,7 @@ public function run( ContainerInterface $container ): bool {
113115
);
114116

115117
/**
116-
* Adds new settings discovery notice.
118+
* Adds notes to old UI settings screens.
117119
*
118120
* @param Message[] $notices
119121
* @return Message[]
@@ -135,6 +137,35 @@ static function ( array $notices ) use ( $container ): array {
135137
);
136138

137139
$notices[] = new Message( $message, 'info', false, 'ppcp-notice-wrapper' );
140+
141+
$is_paylater_messaging_force_enabled_feature_flag_enabled = apply_filters(
142+
// phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores -- feature flags use this convention
143+
'woocommerce.feature-flags.woocommerce_paypal_payments.paylater_messaging_force_enabled',
144+
true
145+
);
146+
147+
$messages_apply = $container->get( 'button.helper.messages-apply' );
148+
assert( $messages_apply instanceof MessagesApply );
149+
150+
$settings = $container->get( 'wcgateway.settings' );
151+
assert( $settings instanceof Settings );
152+
153+
$stay_updated = $settings->has( 'stay_updated' ) && $settings->get( 'stay_updated' );
154+
155+
if ( $is_paylater_messaging_force_enabled_feature_flag_enabled && $messages_apply->for_country() && $stay_updated ) {
156+
$paylater_enablement_message = sprintf(
157+
// translators: %1$s is the URL for Stay Updated setting, %2$s is the URL for Pay Later settings.
158+
__(
159+
'<strong>PayPal Pay Later messaging successfully enabled</strong>, now displaying this flexible payment option earlier in the shopping experience. This update was made based on your <a href="%1$s">Stay Updated</a> preference and can be customized or disabled through the <a href="%2$s">Pay Later settings</a>.',
160+
'woocommerce-paypal-payments'
161+
),
162+
admin_url( 'admin.php?page=wc-settings&tab=checkout&section=ppcp-gateway&ppcp-tab=ppcp-connection#ppcp-stay_updated_field' ),
163+
admin_url( 'admin.php?page=wc-settings&tab=checkout&section=ppcp-gateway&ppcp-tab=ppcp-pay-later' )
164+
);
165+
166+
$notices[] = new Message( $paylater_enablement_message, 'info', false, 'ppcp-notice-wrapper' );
167+
}
168+
138169
return $notices;
139170
}
140171
);

0 commit comments

Comments
 (0)