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.

This issue can also result in you being locked out of the server altogether.

How to load jQuery Cookie on a server using mod_security

1. Log in to FTP or cPanel and rename two files inside the folder /plugins/woocommerce/assets/js/jquery-cookie/:

- rename jquery.cookie.js to jquery_cookie.js
- rename query.cookie.min.js to jquery_cookie.min.js

2. Inside the folder /wp-content/themes/ find theme which is in use, for example, twentyfourtee, and create blank file inside theme folder called custom-functions.php

3. Add the following lines inside your 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 our custom-functions.php.txt example file, and either rename it into custom-functions.php, or copy and paste the content into your existing custom-functions.php file.

4. Save the file.

Now the two javascript files won't produce 404 errors and trigger a mod_security exception.

  • 3 Users Found This Useful
Was this answer helpful?

Related Articles

How to choose your Shopping Cart Software

Many people look for free shopping cart software as a way to start an online store. This can be...