diff --git a/modules/ppcp-onboarding/services.php b/modules/ppcp-onboarding/services.php index 81e25ad31..13bacfc89 100644 --- a/modules/ppcp-onboarding/services.php +++ b/modules/ppcp-onboarding/services.php @@ -133,7 +133,8 @@ return array( $container->get( 'onboarding.url' ), $state, $container->get( 'onboarding.environment' ), - $login_seller_endpoint + $login_seller_endpoint, + $container->get( 'wcgateway.current-ppcp-settings-page-id' ) ); }, diff --git a/modules/ppcp-onboarding/src/Assets/OnboardingAssets.php b/modules/ppcp-onboarding/src/Assets/OnboardingAssets.php index b05bd3023..89628860f 100644 --- a/modules/ppcp-onboarding/src/Assets/OnboardingAssets.php +++ b/modules/ppcp-onboarding/src/Assets/OnboardingAssets.php @@ -12,6 +12,7 @@ namespace WooCommerce\PayPalCommerce\Onboarding\Assets; use WooCommerce\PayPalCommerce\Onboarding\Endpoint\LoginSellerEndpoint; use WooCommerce\PayPalCommerce\Onboarding\Environment; use WooCommerce\PayPalCommerce\Onboarding\State; +use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway; /** * Class OnboardingAssets @@ -46,6 +47,13 @@ class OnboardingAssets { */ private $login_seller_endpoint; + /** + * ID of the current PPCP gateway settings page, or empty if it is not such page. + * + * @var string + */ + protected $page_id; + /** * OnboardingAssets constructor. * @@ -53,18 +61,21 @@ class OnboardingAssets { * @param State $state The State object. * @param Environment $environment The Environment. * @param LoginSellerEndpoint $login_seller_endpoint The LoginSeller endpoint. + * @param string $page_id ID of the current PPCP gateway settings page, or empty if it is not such page. */ public function __construct( string $module_url, State $state, Environment $environment, - LoginSellerEndpoint $login_seller_endpoint + LoginSellerEndpoint $login_seller_endpoint, + string $page_id ) { $this->module_url = untrailingslashit( $module_url ); $this->state = $state; $this->environment = $environment; $this->login_seller_endpoint = $login_seller_endpoint; + $this->page_id = $page_id; } /** @@ -149,7 +160,6 @@ class OnboardingAssets { * @return bool */ private function should_render_onboarding_script(): bool { - global $current_section; - return 'ppcp-gateway' === $current_section; + return PayPalGateway::ID === $this->page_id; } }