I've got a wordpress website running with Woocommerce and WPML plugin for multilingual. On the checkout page, I'm have a javascript error (and I'm no good with js).
Error is :
Uncaught TypeError: Object function (a,b){return new e.fn.init(a,b,h)} has no method 'removeCookie'
Here what calls the error :
jQuery(document).ready(function(){
if(jQuery.cookie != undefined) {
// Check if cookie are enabled
jQuery.cookie('wpml_browser_redirect_test', '1');
var cookie_enabled = jQuery.cookie('wpml_browser_redirect_test') == 1;
jQuery.removeCookie('wpml_browser_redirect_test');
...
And here's the file with the function :
(function ($, document, undefined) {
var pluses = /\+/g;
function raw(s) {
return s;
}
function decoded(s) {
return decodeURIComponent(s.replace(pluses, ' '));
}
$.cookie = function (key, value, options) {
// key and at least value given, set cookie...
if (value !== undefined && !/Object/.test(Object.prototype.toString.call(value))) {
options = $.extend({}, $.cookie.defaults, options);
if (value === null) {
options.expires = -1;
}
if (typeof options.expires === 'number') {
var days = options.expires, t = options.expires = new Date();
t.setDate(t.getDate() + days);
}
value = String(value);
return (document.cookie = [
encodeURIComponent(key), '=', options.raw ? value : encodeURIComponent(value),
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
options.path ? '; path=' + options.path : '',
options.domain ? '; domain=' + options.domain : '',
options.secure ? '; secure' : ''
].join(''));
}
// key and possibly options given, get cookie...
options = value || $.cookie.defaults || {};
var decode = options.raw ? raw : decoded;
var cookies = document.cookie.split('; ');
for (var i = 0, parts; (parts = cookies[i] && cookies[i].split('=')); i++) {
if (decode(parts.shift()) === key) {
return decode(parts.join('='));
}
}
return null;
};
$.cookie.defaults = {};
$.removeCookie = function (key, options) {
if ($.cookie(key, options) !== null) {
$.cookie(key, null, options);
return true;
}
return false;
};
})(jQuery, document);
As I don't know javascript, I really don't know what to think about it. I know that "Object function has no method" is a common problem, I've looked at others posts but I can't figure it.
So guys (and girls), I need help on this one.
Thanks
Bruno