FacebookTwitter

jQuery Conflict in WordPress 4.5 and WooCommerce 2.5

Having an issue with your WooCommerce site since you upgraded to WordPress 4.5? It might be the new version of jQuery that’s causing the problem. Here is a quick fix for jQuery issue.

By on Apr 15, 2016 in Geek | 0 comments

Share On GoogleShare On FacebookShare On Twitter

If your WooCommerce site is having a problem since you upgraded your WordPress to version 4.5, the problem might be associated with jQuery version that came with the new WordPress.

WordPress 4.5 “Coleman” comes with jQuery 1.12.3, the first version 1.12.0+. Previously it was using 1.11.x.

Check to see if your site generates script error(s). My script error after the WordPress upgrade was

Syntax error, unrecognized expression: a[href*=#]:not([href=#])

I discovered when I wasn’t able to add a variable product to a shopping cart (the product page did not show the product price after all the options are selected, and displayed “please choose options” message)

Solutions

If you haven’t upgraded WordPress 4.5, my recommendation is to hold off the ugprade for now. If you already have upgraded, then you can add the following code to your theme’s functions.php to downgrade jQuery version:

// Downgrade to jQuery given version
function downgrade_jquery() {
  global $wp_scripts;
 
  if ( !is_admin() ) :
    wp_deregister_script('jquery');
    wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js', false, '1.11.3');
  endif;
}
add_action( 'wp_head', downgrade_jquery() );

Photo credit: Peregrino Will Reign via Foter.com / CC BY-NC-SA

Leave a Reply