Php – Woocommerce add to cart ajax not working

ajaxPHPwoocommerceWordpress

I'm developing a theme for woocommerce plugin (2.0.12) in wordpress (3.5.1).

In my home page I've added featured products, recent products & top rated products through shortcode which are appearing fine.

Problem: The 'Add to Cart' buttons AJAX is not working. Instead of the AJAX call, the page reloads on clicking the 'Add to Cart' button of an individual product. I've added the cart.min.js in the page, but still the problem persists. It seems that the js variable woocommerce_meta is not getting loaded.

The url is:http://demo.pixelpoetics.net/ecommerce

Thank you in advance.

Best Answer

Check if your 'Add to cart-button' has the following classes: .add_to_cart_button, .product_type_simple. Also check if the button has the dataAttr data-product_id. These items should be given, otherwise neither the add-to-cart.js will trigger the ajaxcall, nor will return a false, which prevents from loading a new page.

If your checking will show these lacks, try to edit the specific templates.

Related Topic