Guide

WooCommerce add to cart button not working? How to find the cause

Add to cart does nothing, spins, or says it worked while the cart stays empty. Each of those points at a different cause, and the browser shows you which.

Updated

The short answer

What the button does tells you where to look:

  • Nothing happens — a JavaScript error, a script held back by an optimisation plugin, or a variable product with no option chosen;
  • It spins and never finishes — the add-to-cart request failed: a PHP error, a firewall or a plugin conflict;
  • It says added, but the cart is empty — caching, or a session cookie that isn't kept;
  • The cart is right, but the header count isn't — cart fragments cached or not loading.

The browser console and the Network tab tell you which in a couple of minutes.

How Add to cart works

WooCommerce adds to the cart in two ways, and they break differently:

  • On shop and category pages, if Enable AJAX add to cart buttons on archives is ticked under WooCommerce → Settings → Products, a script sends the product to ?wc-ajax=add_to_cart without reloading the page, then refreshes the mini-cart.
  • On a product page with a classic theme, the button submits a form and the page reloads with an “added to your cart” notice — unless a theme or plugin turns that into an AJAX request too. Block themes use their own Add to cart blocks.

The same settings page has Redirect to the cart page after successful addition: if it is ticked, shoppers go straight to the cart, which hides some of the problems below — and can look like the button “doesn't work” when the cart page itself is broken.

How to find the cause, step by step

  1. Reproduce it as a shopper. A private window, logged out — you probably bypass the cache as an admin, and your shoppers don't.
  2. Open the Console tab in the developer tools (right-click → Inspect) and press Add to cart. A red error names the file it came from, and the folder under wp-content/plugins/ or themes/ names whose it is. How to read these errors.
  3. Open the Network tab and press it again. Look for ?wc-ajax=add_to_cart on archives, or the POST to the product page on a product page. A 500 or HTML where JSON should be means a PHP error; 403 means a firewall or security plugin; a cached response with an old date means caching.
  4. Check the logs. WooCommerce → Status → Logs keeps fatal errors, and the debug log keeps the rest — where WooCommerce keeps PHP errors.
  5. Isolate a conflict. With the Health Check & Troubleshooting plugin, test with only WooCommerce active and a default theme, for your browser alone. If it works, add the others back one by one.

JavaScript errors and script optimisation

AJAX add to cart, variation choosers and the mini-cart all depend on jQuery and WooCommerce's own scripts. An error in any script that runs first can stop them, and so can an optimisation plugin that delays, defers or combines them:

  • Exclude jquery, WooCommerce's add-to-cart, add-to-cart-variation and cart-fragments scripts from “delay JavaScript” and combine settings, then purge the cache.
  • Check custom code that changes the button — a quantity selector, a “buy now” button, a product add-ons plugin. These are common after a theme update.

Caching, sessions and cart fragments

WooCommerce remembers a guest's cart with a session cookie. When the product is added but the cart shows empty, something between the shopper and the store is losing it:

  • Page cache. The cart, checkout and my-account pages must be excluded, and a visitor with a cart — WooCommerce sets woocommerce_items_in_cart and wp_woocommerce_session_… cookies — should bypass the cache. Most caching plugins and hosts do this for WooCommerce; a CDN set to “cache everything” often doesn't.
  • Cookies not saved. A cookie banner set to block every cookie, including WooCommerce's necessary ones, or a CDN rule that strips Set-Cookie from responses, means each page starts with a new, empty cart.
  • Two addresses for one store. If some links go to www. and others don't, or to http:// and https://, the cookie set on one isn't sent to the other. Redirect everything to one address and check Settings → General.
  • Cart fragments. The mini-cart and header count are refreshed by a request to ?wc-ajax=get_refreshed_fragments. Recent WooCommerce versions only load the fragments script where a mini-cart needs it, so a theme that expects it everywhere can show a stale count. Make sure the request is not cached and not blocked.

Variable products

On a variable product the button stays greyed out until the shopper picks every attribute. If it stays disabled or says the product is unavailable after choosing:

  • The combination doesn't exist — a variation for those options was never created, or “Any” was not set where it should be.
  • The variation has no price, isn't enabled, or is out of stock. A variation with an empty price can't be bought.
  • Many variations. Above a threshold (30 by default), WooCommerce stops putting every variation in the page and asks the server for each combination. If that request fails or is cached, choosing options seems to do nothing.
  • A swatches plugin that replaces the dropdowns but no longer talks to WooCommerce's variation script after an update.

When the product can't be bought

A missing button, or a notice that the product cannot be purchased, is often deliberate: no regular price, stock at zero with backorders off, Sold individually with one already in the cart, or a catalogue-mode or quote plugin. Check the product's General and Inventory tabs before chasing scripts.

Seeing it in StorePilot

A shopper whose Add to cart does nothing rarely tells you — they leave, and your traffic looks normal while sales drop. StorePilot shows you what they ran into:

  • JavaScript and PHP errors grouped into issues, with how many visits by people they reached and where in the code they came from — theme, plugins or WordPress core.
  • The steps before each error: the clicks, and the requests the page made to your own site with their status — WooCommerce's wc-ajax route name is kept, so a failing add-to-cart or fragments request reads as itself.
  • Session recordings linked to an issue wherever the visit was recorded, and dead clicks and rage clicks marked in them — a button that changes nothing when pressed, or one pressed again and again. More in rage clicks and dead clicks.

Install the WordPress plugin — no theme or code changes — or see how error tracking works and read about error tracking in the docs.

Before you call it fixed

  • Add to cart works logged out, on a phone and a desktop, from a category page and a product page.
  • A variable product adds the chosen variation, and the header count updates without a reload.
  • The cart still holds the product after moving to another page and back.
  • The console is free of red errors on product and category pages.
FAQ

Questions about this guide

Why does the WooCommerce Add to cart button do nothing?

On a shop or category page, usually a JavaScript error that stops WooCommerce's add-to-cart script — from a plugin, the theme or a script optimiser. On a variable product, the button stays disabled until every option is chosen and a variation that is in stock and has a price matches. The browser console shows which.

Why is the cart empty after adding a product?

The product was added, but the page you see next doesn't show it: a cached cart or mini-cart, a session cookie that was blocked or not saved, or a mix of www and non-www or http and https addresses that splits the session. Exclude the cart and checkout from caching and serve the store from one address.

Why doesn't the mini-cart count update after Add to cart?

The count is refreshed by WooCommerce's cart fragments. If that request is cached, blocked by an optimisation plugin or never loaded by the theme, the product is in the cart but the header still shows the old number until the page reloads.

Why is there no Add to cart button at all?

WooCommerce hides it when a product can't be bought: no price, out of stock, or a variable product whose variations have no prices. A catalogue-mode or quote plugin, or a theme setting, can also remove it on purpose.

See the clicks on Add to cart that went nowhere

Install the plugin, and the errors behind a dead button reach you with the replay of the shopper who pressed it.

Start for free

Every feature on the Free plan, for 100 visitors a month. No card required.

Choose a plan

Plans from €29 a month, priced by your monthly visitors and the websites you connect.