mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-07 18:00:15 +08:00
🚧 Update boot.js to same logic as Google Pay
This commit is contained in:
parent
b78a1a112a
commit
c00c9c2e13
1 changed files with 17 additions and 13 deletions
|
@ -4,24 +4,28 @@ import ApplePayManager from './ApplepayManager';
|
||||||
import { setupButtonEvents } from '../../../ppcp-button/resources/js/modules/Helper/ButtonRefreshHelper';
|
import { setupButtonEvents } from '../../../ppcp-button/resources/js/modules/Helper/ButtonRefreshHelper';
|
||||||
|
|
||||||
( function ( { buttonConfig, ppcpConfig } ) {
|
( function ( { buttonConfig, ppcpConfig } ) {
|
||||||
let manager;
|
|
||||||
|
|
||||||
const bootstrap = function () {
|
const bootstrap = function () {
|
||||||
manager = new ApplePayManager( buttonConfig, ppcpConfig );
|
if ( ! buttonConfig || ! ppcpConfig ) {
|
||||||
manager.init();
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const manager = new ApplePayManager( buttonConfig, ppcpConfig );
|
||||||
|
|
||||||
|
setupButtonEvents( function () {
|
||||||
|
manager.reinit();
|
||||||
|
} );
|
||||||
};
|
};
|
||||||
|
|
||||||
setupButtonEvents( function () {
|
|
||||||
if ( manager ) {
|
|
||||||
manager.reinit();
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
|
|
||||||
document.addEventListener( 'DOMContentLoaded', () => {
|
document.addEventListener( 'DOMContentLoaded', () => {
|
||||||
if (
|
if ( ! buttonConfig || ! ppcpConfig ) {
|
||||||
typeof buttonConfig === 'undefined' ||
|
/*
|
||||||
typeof ppcpConfig === 'undefined'
|
* No PayPal buttons present on this page, but maybe a bootstrap module needs to be
|
||||||
) {
|
* initialized. Skip loading the SDK or gateway configuration, and directly initialize
|
||||||
|
* the module.
|
||||||
|
*/
|
||||||
|
bootstrap();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue