Fix GooglePay and ApplePay loading scripts on admin standard payments page.

This commit is contained in:
Pedro Silva 2023-11-13 13:55:08 +00:00
parent ac7779bc41
commit c8d4c12a2d
No known key found for this signature in database
GPG key ID: E2EE20C0669D24B3
3 changed files with 9 additions and 2 deletions

View file

@ -164,6 +164,7 @@ class ApplepayModule implements ModuleInterface {
assert( $smart_button instanceof SmartButtonInterface );
if ( $smart_button->should_load_ppcp_script() ) {
$button->enqueue();
return;
}
if ( has_block( 'woocommerce/checkout' ) || has_block( 'woocommerce/cart' ) ) {
@ -196,7 +197,7 @@ class ApplepayModule implements ModuleInterface {
add_action(
'admin_enqueue_scripts',
static function () use ( $c, $button ) {
if ( ! is_admin() ) {
if ( ! is_admin() || ! $c->get( 'wcgateway.is-ppcp-settings-standard-payments-page' ) ) {
return;
}

View file

@ -94,6 +94,7 @@ class GooglepayModule implements ModuleInterface {
assert( $smart_button instanceof SmartButtonInterface );
if ( $smart_button->should_load_ppcp_script() ) {
$button->enqueue();
return;
}
if ( has_block( 'woocommerce/checkout' ) || has_block( 'woocommerce/cart' ) ) {
@ -111,7 +112,7 @@ class GooglepayModule implements ModuleInterface {
add_action(
'admin_enqueue_scripts',
static function () use ( $c, $button ) {
if ( ! is_admin() ) {
if ( ! is_admin() || ! $c->get( 'wcgateway.is-ppcp-settings-standard-payments-page' ) ) {
return;
}

View file

@ -182,6 +182,11 @@ return array(
);
},
'wcgateway.is-ppcp-settings-standard-payments-page' => static function ( ContainerInterface $container ): bool {
return $container->get( 'wcgateway.is-ppcp-settings-page' )
&& $container->get( 'wcgateway.current-ppcp-settings-page-id' ) === PayPalGateway::ID;
},
'wcgateway.current-ppcp-settings-page-id' => static function ( ContainerInterface $container ): string {
if ( ! $container->get( 'wcgateway.is-ppcp-settings-page' ) ) {
return '';