mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
avoid adding JS when fastlane is disabled
This commit is contained in:
parent
947f20a2a5
commit
0b48d9c227
1 changed files with 12 additions and 5 deletions
|
@ -247,7 +247,10 @@ class AxoModule implements ServiceModule, ExtendingModule, ExecutableModule {
|
||||||
add_filter(
|
add_filter(
|
||||||
'woocommerce_paypal_payments_sdk_components_hook',
|
'woocommerce_paypal_payments_sdk_components_hook',
|
||||||
function( $components ) use ( $c ) {
|
function( $components ) use ( $c ) {
|
||||||
if ( ! $c->has( 'axo.available' ) || ! $c->get( 'axo.available' ) ) {
|
$dcc_configuration = $c->get( 'wcgateway.configuration.dcc' );
|
||||||
|
assert( $dcc_configuration instanceof DCCGatewayConfiguration );
|
||||||
|
|
||||||
|
if ( ! $dcc_configuration->use_fastlane() ) {
|
||||||
return $components;
|
return $components;
|
||||||
}
|
}
|
||||||
$components[] = 'fastlane';
|
$components[] = 'fastlane';
|
||||||
|
@ -258,14 +261,18 @@ class AxoModule implements ServiceModule, ExtendingModule, ExecutableModule {
|
||||||
add_action(
|
add_action(
|
||||||
'wp_head',
|
'wp_head',
|
||||||
function () use ( $c ) {
|
function () use ( $c ) {
|
||||||
// phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript
|
|
||||||
echo '<script async src="https://www.paypalobjects.com/insights/v1/paypal-insights.sandbox.min.js"></script>';
|
|
||||||
|
|
||||||
// Add meta tag to allow feature-detection of the site's AXO payment state.
|
// Add meta tag to allow feature-detection of the site's AXO payment state.
|
||||||
$dcc_configuration = $c->get( 'wcgateway.configuration.dcc' );
|
$dcc_configuration = $c->get( 'wcgateway.configuration.dcc' );
|
||||||
assert( $dcc_configuration instanceof DCCGatewayConfiguration );
|
assert( $dcc_configuration instanceof DCCGatewayConfiguration );
|
||||||
|
|
||||||
$this->add_feature_detection_tag( $dcc_configuration->use_fastlane() );
|
if ( $dcc_configuration->use_fastlane() ) {
|
||||||
|
// phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript
|
||||||
|
echo '<script async src="https://www.paypalobjects.com/insights/v1/paypal-insights.sandbox.min.js"></script>';
|
||||||
|
|
||||||
|
$this->add_feature_detection_tag( true );
|
||||||
|
} else {
|
||||||
|
$this->add_feature_detection_tag( false );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue