Add to cart not working
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

I have submitted this to Wordpress and to the Template developer but with some recent updates, I can not determine what is going on with my site.

The site in question is Visit any product page, specifically, let's say this one ;
I've tried on a Mac (Safari and Chrome) and on a PC (Chrome and Explorer) but I see the same errors. The issue is that when you design a product and click add to cart the product does not addto cart. It only works when i am logged in as a admin, but the js errors are there even when i am logged in.

[Error] SyntaxError: Unexpected token '<'
(anonymous function) (, line 1)
[Error] TypeError: undefined is not a function (evaluating 'a.cookie("woocommerce_items_in_cart")')
(anonymous function) (cart-fragments.min.js, line 1)
j (jquery.js, line 2)
fireWith (jquery.js, line 2)
ready (jquery.js, line 2)
J (jquery.js, line 2)

Here's what I've read about and tried to do to fix the issue.
1) I've pointed out the issue to the hosting company. They do not see anything conflicting on their end with this, they think it's a plugin issue.
2) I've disabled all the major plugin's that I felt in some way could effect this and nothing has worked.
3) I've read that it 'could' be that there's a line of code referencing the wrong version of jquery. If that's so, I don't know how to determine where that is.
5) I've refreshed the woo commerce product itself, no effect.
6) I've checked the 'system status' in woo commerce. No issues.
7) I've checked for updates on woo commerce, and other various plug-in's. No luck.
8) kuck
This cropped up randomly but it's preventing ALL sales so I'm hoping to quickly find a fix!

The similar bountify thread that had a resolution is

awarded to dekkard

Crowdsource coding tasks.

1 Solution

Winning solution

Looks like your jquery-cookie.js isn't loaded properly from the specified URL
( ).

If you try to access it, the server responds with 301 "Moved permanently" and you get redirected to the store front page.
This is the reason you see the "a.cookie is not a function" error.

In fact, if you try this URL - - it's going to load fine.

Thus I assume you tried to follow the solution for the mod_security problem you mentioned in your point #8,
but didn't rename the .js file.

The solution would be either:

  • to rename the jquery.cookie.min.js (with a dot) to jquery_cookie.min.js (with an underscore) and to make sure the following code exists in your theme functions.php file (note how "jquery_cookie" is written with underscores - as in the new file name):

    add_action( 'wp_enqueue_scripts', 'custom_frontend_scripts' );
    function custom_frontend_scripts() {
        global $post, $woocommerce;
        $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
        wp_deregister_script( 'jquery-cookie' );
        wp_register_script( 'jquery-cookie', 
                $woocommerce->plugin_url() . '/assets/js/jquery-cookie/jquery_cookie' . $suffix . '.js', 
                array( 'jquery' ), 
                true );
  • or to use the WP plugin "WooCommerce jQuery Cookie Fix" found here -
    ( In case it's unavailable I've mirrored it to )