mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +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 =
|
const wcShipmentTaxBuyLabelButtonSelector =
|
||||||
'.components-modal__screen-overlay .label-purchase-modal__sidebar .purchase-section button.components-button';
|
'.components-modal__screen-overlay .label-purchase-modal__sidebar .purchase-section button.components-button';
|
||||||
|
const dhlGenerateLabelButton =
|
||||||
|
document.getElementById( 'dhl-label-button' );
|
||||||
|
|
||||||
const toggleLoaderVisibility = function () {
|
const toggleLoaderVisibility = function () {
|
||||||
const loader = document.querySelector( '.ppcp-tracking-loader' );
|
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 (
|
if (
|
||||||
gzdSyncEnabled &&
|
gzdSyncEnabled &&
|
||||||
typeof gzdSaveButton !== 'undefined' &&
|
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 (
|
if (
|
||||||
wcShippingTaxSyncEnabled &&
|
wcShippingTaxSyncEnabled &&
|
||||||
typeof wcShippingTaxSyncEnabled !== 'undefined' &&
|
typeof wcShippingTaxSyncEnabled !== 'undefined'
|
||||||
wcShippingTaxSyncEnabled != null
|
|
||||||
) {
|
) {
|
||||||
document.addEventListener( 'click', function ( event ) {
|
document.addEventListener( 'click', function ( event ) {
|
||||||
const wcShipmentTaxBuyLabelButton = event.target.closest(
|
const wcShipmentTaxBuyLabelButton = event.target.closest(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue