mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-31 06:52:50 +08:00
Merge pull request #507 from woocommerce/fix-onboarding-js-loading
Load onboarding assets only on the first tab
This commit is contained in:
commit
4fa6c30595
2 changed files with 15 additions and 4 deletions
|
@ -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' )
|
||||
);
|
||||
},
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue