News

“a.cookie is not a function” error in WooCommerce 3.2.5

December 7, 2017

In the latest version of WooCommerce 3.2.5 (as of today), there is an error which may cause all of javascript code on your site to stop working. If you hit F12 to open the inspector window, you will see this message in the console log

Uncaught TypeError: a.cookie is not a function
at HTMLDocument. (cart-fragments.min.js?ver=2.6.14:1)
at i (jquery.js?ver=1.12.4:2)
at Object.fireWith [as resolveWith] (jquery.js?ver=1.12.4:2)
at Function.ready (jquery.js?ver=1.12.4:2)
at HTMLDocument.K (jquery.js?ver=1.12.4:2)

It’s not your fault or your theme, it’s related to WooCommerce. They have changed from jQuery Cookie to Vanilla JS Cookie https://github.com/js-cookie/js-cookie in to work with latest version of jQuery in WordPress 4.9+. The updated file is cart-fragments.min.js but tthe minified file (.min.js) is not re-minified. Only the raw file cart-fragments.js has the new code. To fix this error, you can open /woocommerce/assets/js/frontend/cart-fragments.js , copy all the code, and open an online minify tool such as https://www.minifier.org/  to get the minified code. Copy the minified code and replace all code in the .min.js file. Voala, it should work the issue.

An easier option: wait for WooCommerce to update  😉

You Might Also Like