WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
add to cart button missing after update (6 posts)

  1. Tboucher21
    Member
    Posted 10 months ago #

    i updated to version 3.6.1 a couple days ago and my add to cart button is now gone. I have done some research and know that it is most likely a JavaScript error. I have diagnosed it with my browser and found a couple of errors.

    Uncaught TypeError: Cannot read property '358' of undefined add-to-cart-variation.min.js?ver=2.0.14:3

    Uncaught TypeError: Object function (e,t){return new x.fn.init(e,t,r)} has no method 'cookie' cart-fragments.min.js?ver=2.0.14:1

    I have no idea how to fix this error, and help would GREATLY be appreciated.

    http://wordpress.org/plugins/woocommerce/

  2. j2db87
    Member
    Posted 10 months ago #

    I'm receiving the same thing, even though Woocommerce has done an update to their plugin today, the java error is still there causing the shopping cart to not work.

    I believe also as well, that it was due to the WordPress update because it was not like this before. Theme developers told me that it may have something to do with the plugins and I need deactivate them (which I did and nothing had changed), others say it may be the woocommerce plugin using pares instead of parse but I've looked and that's not it either.

    I'm hoping to find a resolution to this as well. I will keep checking.
    To see the error on my website go to: http://crewnation.com/shop/men_women/crewnation-the-brand-2/

  3. nga1105
    Member
    Posted 10 months ago #

    you can add code in top of file cart-fragments.min.js. It worked for me.

    jQuery.noConflict();
    (function (factory) {
            if (typeof define === 'function' && define.amd) {
                    // AMD. Register as anonymous module.
                    define(['jquery'], factory);
            } else {
                    // Browser globals.
                    factory(jQuery);
            }
    }(function ($) {
    
            var pluses = /\+/g;
    
            function encode(s) {
                    return config.raw ? s : encodeURIComponent(s);
            }
    
            function decode(s) {
                    return config.raw ? s : decodeURIComponent(s);
            }
    
            function stringifyCookieValue(value) {
                    return encode(config.json ? JSON.stringify(value) : String(value));
            }
    
            function parseCookieValue(s) {
                    if (s.indexOf('"') === 0) {
                            // This is a quoted cookie as according to RFC2068, unescape...
                            s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
                    }
    
                    try {
                            // Replace server-side written pluses with spaces.
                            // If we can't decode the cookie, ignore it, it's unusable.
                            s = decodeURIComponent(s.replace(pluses, ' '));
                    } catch(e) {
                            return;
                    }
    
                    try {
                            // If we can't parse the cookie, ignore it, it's unusable.
                            return config.json ? JSON.parse(s) : s;
                    } catch(e) {}
            }
    
            function read(s, converter) {
                    var value = config.raw ? s : parseCookieValue(s);
                    return $.isFunction(converter) ? converter(value) : value;
            }
    
            var config = $.cookie = function (key, value, options) {
    
                    // Write
                    if (value !== undefined && !$.isFunction(value)) {
                            options = $.extend({}, config.defaults, options);
    
                            if (typeof options.expires === 'number') {
                                    var days = options.expires, t = options.expires = new Date();
                                    t.setDate(t.getDate() + days);
                            }
    
                            return (document.cookie = [
                                    encode(key), '=', stringifyCookieValue(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(''));
                    }
    
                    // Read
    
                    var result = key ? undefined : {};
    
                    // To prevent the for loop in the first place assign an empty array
                    // in case there are no cookies at all. Also prevents odd result when
                    // calling $.cookie().
                    var cookies = document.cookie ? document.cookie.split('; ') : [];
    
                    for (var i = 0, l = cookies.length; i < l; i++) {
                            var parts = cookies[i].split('=');
                            var name = decode(parts.shift());
                            var cookie = parts.join('=');
    
                            if (key && key === name) {
                                    // If second argument (value) is a function it's a converter...
                                    result = read(cookie, value);
                                    break;
                            }
    
                            // Prevent storing a cookie that we couldn't decode.
                            if (!key && (cookie = read(cookie)) !== undefined) {
                                    result[name] = cookie;
                            }
                    }
    
                    return result;
            };
    
            config.defaults = {};
    
            $.removeCookie = function (key, options) {
                    if ($.cookie(key) === undefined) {
                            return false;
                    }
    
                    // Must not alter options, thus extending a fresh object...
                    $.cookie(key, '', $.extend({}, options, { expires: -1 }));
                    return !$.cookie(key);
            };
    
    }));
  4. jameskoster
    Member
    Plugin Author

    Posted 10 months ago #

    Try switching themes and deactivating other plugins. In 3.6 WP updated jQuery so there may be a conflict somewhere.

  5. Tboucher21
    Member
    Posted 10 months ago #

    nga1105:

    I inserted the code you posted in the file cart-fragments.min.js. It didnt seem to change anything. I do believe I have the exact problem that the code you posted should fix. I want to make sure that I am doing everything right when plugging it into that file.

    I simply went to my cPanel, selected the cart-fragments.min.js file, went to code edit, and pasted that code at the very top, above the existing code.

    Is that the correct process for implementing this fix?

    Thanks so much!

  6. wompninja
    Member
    Posted 6 months ago #

    I also tried putting that code in and I get the error
    SyntaxError: missing } after function body

    I can't figure out what is missing.

Reply

You must log in to post.

About this Plugin

About this Topic