diff --git a/modules/ppcp-paylater-configurator/src/PayLaterConfiguratorModule.php b/modules/ppcp-paylater-configurator/src/PayLaterConfiguratorModule.php index 2c13bed71..8e46bcf33 100644 --- a/modules/ppcp-paylater-configurator/src/PayLaterConfiguratorModule.php +++ b/modules/ppcp-paylater-configurator/src/PayLaterConfiguratorModule.php @@ -9,9 +9,11 @@ namespace WooCommerce\PayPalCommerce\PayLaterConfigurator; +use WooCommerce\PayPalCommerce\Onboarding\State; use WooCommerce\PayPalCommerce\PayLaterConfigurator\Endpoint\GetConfig; use WooCommerce\PayPalCommerce\PayLaterConfigurator\Endpoint\SaveConfig; use WooCommerce\PayPalCommerce\PayLaterConfigurator\Factory\ConfigFactory; +use WooCommerce\PayPalCommerce\Settings\Data\OnboardingProfile; use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Module\ExecutableModule; use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Module\ExtendingModule; use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Module\ModuleClassNameIdTrait; @@ -68,8 +70,9 @@ static function () use ( $c ) { $current_page_id = $c->get( 'wcgateway.current-ppcp-settings-page-id' ); $is_wc_settings_page = $c->get( 'wcgateway.is-wc-settings-page' ); $messaging_locations = $c->get( 'paylater-configurator.messaging-locations' ); + $onboarding_profile = $c->get( 'settings.data.onboarding' ); - self::add_paylater_update_notice( $messaging_locations, $is_wc_settings_page, $current_page_id ); + self::add_paylater_update_notice( $messaging_locations, $is_wc_settings_page, $current_page_id, $onboarding_profile ); $settings = $c->get( 'wcgateway.settings' ); assert( $settings instanceof Settings ); @@ -159,13 +162,19 @@ static function () use ( $c ) { * The notice appears on any PayPal-Settings page, except for the Pay-Later settings page, * when no Pay-Later messaging is used yet. * - * @param array $message_locations PayLater messaging locations. - * @param bool $is_settings_page Whether the current page is a WC settings page. - * @param string $current_page_id ID of current settings page tab. + * @param array $message_locations PayLater messaging locations. + * @param bool $is_settings_page Whether the current page is a WC settings page. + * @param string $current_page_id ID of current settings page tab. + * @param OnboardingProfile $onboarding_profile Onboarding profile. * * @return void */ - private static function add_paylater_update_notice( array $message_locations, bool $is_settings_page, string $current_page_id ) : void { + private static function add_paylater_update_notice( array $message_locations, bool $is_settings_page, string $current_page_id, OnboardingProfile $onboarding_profile ) : void { + // Don't display the notice if the user has not completed the onboarding process. + if ( $onboarding_profile->get_completed() !== true ) { + return; + } + // The message must be registered on any WC-Settings page, except for the Pay Later page. if ( ! $is_settings_page || Settings::PAY_LATER_TAB_ID === $current_page_id ) { return; diff --git a/modules/ppcp-settings/resources/js/Components/App.js b/modules/ppcp-settings/resources/js/Components/App.js index 1b08de16e..69aaabe19 100644 --- a/modules/ppcp-settings/resources/js/Components/App.js +++ b/modules/ppcp-settings/resources/js/Components/App.js @@ -2,13 +2,18 @@ import { useEffect, useMemo } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import classNames from 'classnames'; -import { OnboardingHooks } from '../data'; +import { OnboardingHooks, CommonHooks } from '../data'; import SpinnerOverlay from './ReusableComponents/SpinnerOverlay'; +import SendOnlyMessage from './Screens/SendOnlyMessage'; import OnboardingScreen from './Screens/Onboarding'; import SettingsScreen from './Screens/Settings'; const SettingsApp = () => { const onboardingProgress = OnboardingHooks.useSteps(); + const { + isReady: merchantIsReady, + merchant: { isSendOnlyCountry }, + } = CommonHooks.useMerchantInfo(); // Disable the "Changes you made might not be saved" browser warning. useEffect( () => { @@ -29,7 +34,7 @@ const SettingsApp = () => { } ); const Content = useMemo( () => { - if ( ! onboardingProgress.isReady ) { + if ( ! onboardingProgress.isReady || ! merchantIsReady ) { return ( { ); } + if ( isSendOnlyCountry ) { + return ; + } + if ( ! onboardingProgress.completed ) { return ; } return ; - }, [ onboardingProgress ] ); + }, [ + isSendOnlyCountry, + merchantIsReady, + onboardingProgress.completed, + onboardingProgress.isReady, + ] ); return
{ Content }
; }; diff --git a/modules/ppcp-settings/resources/js/Components/ReusableComponents/SettingsBlocks/FeatureSettingsBlock.js b/modules/ppcp-settings/resources/js/Components/ReusableComponents/SettingsBlocks/FeatureSettingsBlock.js index bcc20c5ef..3f747bda7 100644 --- a/modules/ppcp-settings/resources/js/Components/ReusableComponents/SettingsBlocks/FeatureSettingsBlock.js +++ b/modules/ppcp-settings/resources/js/Components/ReusableComponents/SettingsBlocks/FeatureSettingsBlock.js @@ -24,6 +24,7 @@ const FeatureSettingsBlock = ( { title, description, ...props } ) => {