Skip to content

Instantly share code, notes, and snippets.

@geraldurbas
Last active October 16, 2025 01:32
Show Gist options
  • Save geraldurbas/be1553101292f3dde2cb7c11f8df1e32 to your computer and use it in GitHub Desktop.
Save geraldurbas/be1553101292f3dde2cb7c11f8df1e32 to your computer and use it in GitHub Desktop.
themes function.php ---
add_action('admin_init','load_admin_shipping_cost_bug');
function load_admin_shipping_cost_bug() {
global $pagenow;
if (is_admin() && $pagenow=='admin.php') {
wp_enqueue_script('custom_js_jquery_ui',get_stylesheet_directory_uri() . '/shipping_cost_bug.js',array('jquery'));
}
}
shipping_cost_bug.js ---
let observer = new MutationObserver(mutationRecords => {
mutationRecords.forEach((mutation) => {
mutation.addedNodes.forEach((node) => {
if (mutation.type === "childList" && node.id === "wc-backbone-modal-dialog") {
jQuery(document).ready(function($) {
$('#wc-backbone-modal-dialog').find('.wc-backbone-modal-shipping-method-settings').find('.wc-backbone-modal-action-active').on('click',function(e) {
$('.wc-backbone-modal-shipping-method-settings').find('.wc-shipping-modal-price').each(function(e){
let value = $(this).prop('value')
$(this).after("<span class=replace>"+
value.toString() + ' replace ok? = ' + value.replace('.',',').toString() + '|'
+"</span>"
)
})
if (confirm(
'Kosten für Versandklasse: Bitte das Komma prüfen! Das Tool kann helfen den automatisch fixen!'
)) {
$('.wc-backbone-modal-shipping-method-settings').find('.wc-shipping-modal-price').each(
function(e){
let value = $(this).prop('value')
$(this).prop('value',value.replace('.',','))
console.log($(this).val())
}
)
}
return confirm('Wenn alles passts OK; falls nicht abbrechen!')
}
);
})
};
});
});
});
const targetNode = document.getElementById('wpbody');
observer.observe(document.documentElement, {
childList: true, // observe direct children
subtree: true, // and lower descendants too
characterDataOldValue: true // pass old data to callback
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment