Purpose: Avoid duplicate shipment creation on Create Shipments page when a user tries to click the submit button multiple times.
Code goes to your active theme’s functions.php file:
add_action('wp_footer', function(){
$wpcfe = ($_GET['wpcfe'] ?? '') ?: '';
if(function_exists('wpcfe_admin_page') && wpcfe_admin_page() && ($wpcfe == 'add' || $wpcfe == 'update')) {
?>
<script>
jQuery(document).ready(function($){
let createShipmentForm = $('form.add-shipment');
let updateShipmentForm = $('form.update-shipment');
if(createShipmentForm.length > 0) {
createShipmentForm.on('submit', function(){
$(this).find('button[type="submit"]').attr('disabled', true);
});
}
if(updateShipmentForm.length > 0) {
updateShipmentForm.on('submit', function(){
$(this).find('button[type="submit"]').attr('disabled', true);
});
}
});
</script>
<?php
}
});