Try this to take into functions.php in child theme if you use
// Zruší GLS Shipping skripty
function odstranit_gls_plugin_vystupy() {
// Odstráni GLS skripty a mapu z frontendu
remove_action(‘wp_enqueue_scripts’, array(‘GLS_Shipping_Assets’, ‘load_scripts’));
remove_action(‘wp_footer’, array(‘GLS_Shipping_Assets’, ‘footer_map’));
}
add_action(‘init’, ‘odstranit_gls_plugin_vystupy’, 20);
Try this to take into functions.php in child theme if you use this is turn off a script allover but not in cart and checkout
function odstranit_gls_plugin_vystupy() {
// Skontroluje, či nie sme na stránke košíka alebo pokladne
if ( !is_cart() && !is_checkout() ) {
// Odstráni GLS skripty a mapu z frontendu mimo košíka a pokladne
remove_action(‘wp_enqueue_scripts’, array(‘GLS_Shipping_Assets’, ‘load_scripts’));
remove_action(‘wp_footer’, array(‘GLS_Shipping_Assets’, ‘footer_map’));
}
}
add_action(‘wp’, ‘odstranit_gls_plugin_vystupy’, 20);
or
// Zruší GLS Shipping skripty na všetkých stránkach okrem košíka a pokladne
function odstranit_gls_plugin_vystupy() {
// Skontroluje, či sme na košíku alebo pokladni
if ( is_cart() || is_checkout() ) {
return; // Na týchto stránkach GLS necháme bežať
}
// Odstráni GLS skripty a mapu z frontendu
remove_action('wp_enqueue_scripts', array('GLS_Shipping_Assets', 'load_scripts'));
remove_action('wp_footer', array('GLS_Shipping_Assets', 'footer_map'));
}
add_action(‘wp’, ‘odstranit_gls_plugin_vystupy’, 20);
-
This reply was modified 9 months, 3 weeks ago by
normandy88.
Thread Starter
Vitalii
(@wwvitalik)
@normandy88, thank you for the code.
I’ve already put the following into my child-theme’s functions.php:
function conditionally_load_GLS_plugin_js(){
if (!is_page('cart') && !is_page('checkout')){ // Load GLS shipping JS files only on the Cart and Checkout pages
wp_dequeue_script('gls-shipping-dpm');
wp_dequeue_script('gls-shipping-public');
}
}
add_action( 'wp_enqueue_scripts', 'conditionally_load_GLS_plugin_js', 1099 );
And its works.
Is your solution based on remove_action(); better?
Plugin Contributor
Goran87
(@goran87)
Hey guys, thanks for this, I am adding it in the next week update. We will have a pretty big update that will include this optimization fix as well.
pozdrav,
imamo problem s instalacijom GLS plugina. COD plaćanje ga ne prepoznaje, tako da nemamo taj oblik plaćanja, i kada uspijemo napraviti test narudžbu, podaci nisu preneseni na mygls. Help!