mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 14:57:26 +08:00
Automatically update PayPal Package Tracking Status metabox
This commit is contained in:
parent
40c81683d9
commit
2da1fa0323
1 changed files with 27 additions and 2 deletions
|
@ -15,6 +15,8 @@ document.addEventListener( 'DOMContentLoaded', () => {
|
|||
);
|
||||
const wcShipmentTaxBuyLabelButtonSelector =
|
||||
'.components-modal__screen-overlay .label-purchase-modal__sidebar .purchase-section button.components-button';
|
||||
const dhlGenerateLabelButton =
|
||||
document.getElementById( 'dhl-label-button' );
|
||||
|
||||
const toggleLoaderVisibility = function () {
|
||||
const loader = document.querySelector( '.ppcp-tracking-loader' );
|
||||
|
@ -44,6 +46,20 @@ document.addEventListener( 'DOMContentLoaded', () => {
|
|||
}
|
||||
};
|
||||
|
||||
const waitForButtonRemoval = function ( button ) {
|
||||
if ( document.body.contains( button ) ) {
|
||||
setTimeout( () => waitForButtonRemoval( button ), 100 );
|
||||
} else {
|
||||
jQuery( orderTrackingContainerSelector ).load(
|
||||
loadLocation,
|
||||
'',
|
||||
function () {
|
||||
toggleLoaderVisibility();
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
if (
|
||||
gzdSyncEnabled &&
|
||||
typeof gzdSaveButton !== 'undefined' &&
|
||||
|
@ -66,10 +82,19 @@ document.addEventListener( 'DOMContentLoaded', () => {
|
|||
} );
|
||||
}
|
||||
|
||||
if (
|
||||
typeof dhlGenerateLabelButton !== 'undefined' &&
|
||||
dhlGenerateLabelButton != null
|
||||
) {
|
||||
dhlGenerateLabelButton.addEventListener( 'click', function ( event ) {
|
||||
toggleLoaderVisibility();
|
||||
waitForButtonRemoval( dhlGenerateLabelButton );
|
||||
} );
|
||||
}
|
||||
|
||||
if (
|
||||
wcShippingTaxSyncEnabled &&
|
||||
typeof wcShippingTaxSyncEnabled !== 'undefined' &&
|
||||
wcShippingTaxSyncEnabled != null
|
||||
typeof wcShippingTaxSyncEnabled !== 'undefined'
|
||||
) {
|
||||
document.addEventListener( 'click', function ( event ) {
|
||||
const wcShipmentTaxBuyLabelButton = event.target.closest(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue