mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-04 08:47:23 +08:00
Update the tracking metabox dynamically
This commit is contained in:
parent
54d73fcbae
commit
6f8fe3b7c0
3 changed files with 34 additions and 5 deletions
|
@ -9,7 +9,9 @@ document.addEventListener(
|
|||
const loadLocation = location.href + " " + orderTrackingContainerSelector + ">*";
|
||||
const gzdSyncEnabled = config.gzd_sync_enabled;
|
||||
const wcShipmentSyncEnabled = config.wc_shipment_sync_enabled;
|
||||
const wcShippingTaxSyncEnabled = config.wc_shipping_tax_sync_enabled;
|
||||
const wcShipmentSaveButton = document.querySelector('#woocommerce-shipment-tracking .button-save-form');
|
||||
const wcShipmentTaxBuyLabelButtonSelector = '.components-modal__screen-overlay .label-purchase-modal__sidebar .purchase-section button.components-button';
|
||||
|
||||
const toggleLoaderVisibility = function() {
|
||||
const loader = document.querySelector('.ppcp-tracking-loader');
|
||||
|
@ -45,5 +47,20 @@ document.addEventListener(
|
|||
waitForTrackingUpdate(jQuery('#shipment-tracking-form'));
|
||||
})
|
||||
}
|
||||
|
||||
if (wcShippingTaxSyncEnabled && typeof(wcShippingTaxSyncEnabled) != 'undefined' && wcShippingTaxSyncEnabled != null) {
|
||||
document.addEventListener('click', function(event) {
|
||||
const wcShipmentTaxBuyLabelButton = event.target.closest(wcShipmentTaxBuyLabelButtonSelector);
|
||||
|
||||
if (wcShipmentTaxBuyLabelButton) {
|
||||
toggleLoaderVisibility();
|
||||
setTimeout(function () {
|
||||
jQuery(orderTrackingContainerSelector).load(loadLocation, "", function(){
|
||||
toggleLoaderVisibility();
|
||||
});
|
||||
}, 5000);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
|
|
@ -90,6 +90,7 @@ return array(
|
|||
$container->get( 'ppcp.asset-version' ),
|
||||
$container->get( 'compat.gzd.is_supported_plugin_version_active' ),
|
||||
$container->get( 'compat.wc_shipment_tracking.is_supported_plugin_version_active' ),
|
||||
$container->get( 'compat.wc_shipping_tax.is_supported_plugin_version_active' ),
|
||||
$container->get( 'api.bearer' )
|
||||
);
|
||||
},
|
||||
|
|
|
@ -47,6 +47,13 @@ class CompatAssets {
|
|||
*/
|
||||
protected $is_wc_shipment_active;
|
||||
|
||||
/**
|
||||
* Whether WC Shipping & Tax plugin is active
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $is_wc_shipping_tax_active;
|
||||
|
||||
/**
|
||||
* The bearer.
|
||||
*
|
||||
|
@ -61,6 +68,7 @@ class CompatAssets {
|
|||
* @param string $version The assets version.
|
||||
* @param bool $is_gzd_active Whether Germanized plugin is active.
|
||||
* @param bool $is_wc_shipment_active Whether WC Shipments plugin is active.
|
||||
* @param bool $is_wc_shipping_tax_active Whether WC Shipping & Tax plugin is active.
|
||||
* @param Bearer $bearer The bearer.
|
||||
*/
|
||||
public function __construct(
|
||||
|
@ -68,14 +76,16 @@ class CompatAssets {
|
|||
string $version,
|
||||
bool $is_gzd_active,
|
||||
bool $is_wc_shipment_active,
|
||||
bool $is_wc_shipping_tax_active,
|
||||
Bearer $bearer
|
||||
) {
|
||||
|
||||
$this->module_url = $module_url;
|
||||
$this->version = $version;
|
||||
$this->is_gzd_active = $is_gzd_active;
|
||||
$this->is_wc_shipment_active = $is_wc_shipment_active;
|
||||
$this->bearer = $bearer;
|
||||
$this->module_url = $module_url;
|
||||
$this->version = $version;
|
||||
$this->is_gzd_active = $is_gzd_active;
|
||||
$this->is_wc_shipment_active = $is_wc_shipment_active;
|
||||
$this->is_wc_shipping_tax_active = $is_wc_shipping_tax_active;
|
||||
$this->bearer = $bearer;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -99,6 +109,7 @@ class CompatAssets {
|
|||
array(
|
||||
'gzd_sync_enabled' => apply_filters( 'woocommerce_paypal_payments_sync_gzd_tracking', true ) && $this->is_gzd_active,
|
||||
'wc_shipment_sync_enabled' => apply_filters( 'woocommerce_paypal_payments_sync_wc_shipment_tracking', true ) && $this->is_wc_shipment_active,
|
||||
'wc_shipping_tax_sync_enabled' => apply_filters( 'woocommerce_paypal_payments_sync_wc_shipping_tax', true ) && $this->is_wc_shipping_tax_active,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue