Sunday, February 19, 2023

Wordpress Fixing WooCommerce 7.3.0+ Uncaught TypeError Cookies is defined

How to fix WooCommerce 7.3.0+ Uncaught TypeError : Cookies is undefined 

Recently, upgraded WooCommerce to Version 7.3.0.  

Strangely, I was getting the following error 


The following WooCommerce scripts was included for cookies

1
plugins/woocommerce/assets/js/js-cookie/js.cookie.min.js

Turns out v2.1.4 was release Apr 3, 2017

1
2
3
4
5
6
7
8
/*!
 * JavaScript Cookie v2.1.4
 * https://github.com/js-cookie/js-cookie
 *
 * Copyright 2006, 2015 Klaus Hartl & Fagner Brack
 * Released under the MIT license
 */
;(function (factory) {

Solution 

Upgrading to v3.0.1 released Sep 1, 2021, cleared the error. Why is this not part of the WooCommerce plugin upgrade? 

CDN - https://cdn.jsdelivr.net/npm/js-cookie@3.0.1/dist/js.cookie.js

1
2
wp_deregister_script( 'jquery-cookie' );
wp_enqueue_script( 'jquery-cookie', 'https://cdn.jsdelivr.net/npm/js-cookie@3.0.1/dist/js.cookie.min.js', array( 'jquery' ), '3.0.1', true );

No comments:

Post a Comment