mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
AXO: Only enqueue JS scripts on the WooCommerce checkout page
This commit is contained in:
parent
652f404551
commit
bfb566162c
1 changed files with 8 additions and 4 deletions
|
@ -44,7 +44,6 @@ class AxoModule implements ModuleInterface {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
public function run( ContainerInterface $c ): void {
|
||||
$module = $this;
|
||||
|
||||
add_filter(
|
||||
'woocommerce_payment_gateways',
|
||||
|
@ -132,7 +131,8 @@ class AxoModule implements ModuleInterface {
|
|||
|
||||
add_action(
|
||||
'init',
|
||||
function () use ( $c, $module ) {
|
||||
function () use ( $c ) {
|
||||
$module = $this;
|
||||
|
||||
// Check if the module is applicable, correct country, currency, ... etc.
|
||||
if ( ! $c->get( 'axo.eligible' ) ) {
|
||||
|
@ -145,11 +145,15 @@ class AxoModule implements ModuleInterface {
|
|||
// Enqueue frontend scripts.
|
||||
add_action(
|
||||
'wp_enqueue_scripts',
|
||||
static function () use ( $c, $manager ) {
|
||||
static function () use ( $c, $manager, $module ) {
|
||||
|
||||
$settings = $c->get( 'wcgateway.settings' );
|
||||
assert( $settings instanceof Settings );
|
||||
|
||||
$smart_button = $c->get( 'button.smart-button' );
|
||||
assert( $smart_button instanceof SmartButtonInterface );
|
||||
|
||||
if ( $smart_button->should_load_ppcp_script() ) {
|
||||
if ( $module->should_render_fastlane( $settings ) && $smart_button->should_load_ppcp_script() ) {
|
||||
$manager->enqueue();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue