WooCommerce jQuery Cookie fails to load

Issue: WooCommerce Wordpress plugin fails to load jQuery Cookie Java Script due to current Mod_security ruleset. Two files (jquery.cookie.js and jquery.cookie.min.js), located inside folder /plugins/woocommerce/assets/js/jquery-cookie/ will produce 404 error which may cause some issues with "Order" buttons (impossible to order) and other minor template issues.

How to load jQuery Cookie on Apache server with mod_security:

1. Login to FTP then rename two files inside folder /plugins/woocommerce/assets/js/jquery-cookie/:

jquery.cookie.js into jquery_cookie.js
jquery.cookie.min.js into jquery_cookie.min.js

2. Inside folder /wp-content/themes/ find theme which is in use, for example, twentyfourteen then create blank file inside theme folder:

custom-functions.php

3. Add following lines inside newly created file "custom-functions.php":

add_action( 'wp_enqueue_scripts', 'custom_frontend_scripts' );
function custom_frontend_scripts() {
global , ;
= defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; wp_deregister_script( 'jquery-cookie' ); wp_register_script( 'jquery-cookie', >plugin_url() . '/assets/js/jquery-cookie/jquery_cookie' . . '.js', array( 'jquery' ), '1.3.1', true );
}

Tip: You may also download ready file custom-functions.txt then rename either rename it into custom-functions.php or copy and paste content into custom-functions.php file.

4. Save file

5. Test plugin then backup good working version of Wordpress with WooCommerce plugin.

Now two java script files jquery_cookie.js and jquery_cookie.min.js won't produce 404 errors due to mod_security module interference.

  • Back to HowTos
  • 100% Managed Dedicated Servers

    • 64-128 GB of DDR4 Memory
    • SSD disks
    • Free cPanel/WHM
    • Free Offsite Backups

    Premium Reseller Hosting Plans

    • Unlimited Domains
    • Unlimited Users
    • Free SSL and IPs
    • Save 25% today!