More fixes

WooCommerce "Add to cart" not working

A customer clicks Add to cart and nothing happens. Or the button spins forever, or the page reloads and the cart still says it is empty, or the item shows up for you but not for customers. Nobody can buy, and most of them just leave without telling you. The cause is nearly always one of a few things: a cached page, a script error from a plugin or the theme, the product's own setup, or a cart session that is not being kept. Below is a rebuilt example (not a real client), the two checks that find the cause, and the fix for each one.

Product page

What the checks found


  

Check 1: open the browser console and click the button

On a computer, open the product page, press F12 (or right-click > Inspect) and pick the Console tab. Click Add to cart. A red line such as Uncaught TypeError or jQuery is not defined means a script broke before the button could work; the file name next to it usually names the plugin or theme. Then open the Network tab and click again: you should see a request to ?wc-ajax=add_to_cart (on shop pages) or the page posting back to itself. A 403 there points at a firewall, a 500 at a PHP error, and no request at all at a script problem.

Check 2: test logged out, in a private window

Open a private (incognito) window, go to the shop without logging in, and add the same product. If it works for you as an admin but fails logged out, the page customers see is a cached copy, or the cart cookie is not being saved. If it fails in both, the problem is in the product or a plugin. Also try a second product of a different type (a simple product and one with options) to see if it is one product or all of them.

What each answer means

What you seeCauseFix
Works when logged in, fails for customers; the cart icon shows an old count or stays at 0The shop, cart or checkout page is served from a cache (caching plugin, the host's cache, or Cloudflare "Cache Everything"), so the cart fragments never refreshExclude /cart/, /checkout/ and /my-account/ from every cache, and do not cache pages for visitors who carry the woocommerce_items_in_cart or wp_woocommerce_session_ cookies. Then purge all caches and test logged out again
A red error in the console naming a plugin or theme fileA script error stops WooCommerce's add-to-cart script from runningDeactivate the plugin it names (or switch to a default theme like Storefront for a minute) and test again. Use the Health Check plugin's troubleshooting mode to do this without customers seeing it. Update or replace the one that breaks it
"jQuery is not defined" or nothing in the Network tab after a speed-plugin changeA speed setting delays or defers JavaScript (Delay JS, Defer jQuery, combine/minify JS, Cloudflare Rocket Loader), so the button loads before the script it needsExclude jQuery and the WooCommerce scripts (add-to-cart, cart-fragments, woocommerce) from delay and combine, or turn that one option off, then clear the cache
Product page shows no button at all, or "Read more" instead of "Add to cart"The product has no price, is out of stock, is set to "Catalog" visibility, or is a variable product whose options were never chosenGive the product a regular price, set stock to In stock (or allow backorders), and for products with options check each variation has a price and is enabled. On variable products the button stays grey until the customer picks every option: that is normal
Page reloads, a green "added to your cart" message appears, but the cart is emptyThe cart session is not kept: cookies blocked by a security plugin, the site mixing www and non-www or http and https, or the sessions table not being writtenMake the WordPress Address and Site Address in Settings > General the same exact address (both https, same www), redirect the other versions to it, and check WooCommerce > Status for database errors. See cookies are blocked
Network tab shows 403 on wc-ajax=add_to_cart or on admin-ajax.phpA firewall (Wordfence, the host's ModSecurity, Cloudflare WAF) blocks the requestCheck the firewall's log for the blocked request and allow it, or whitelist the rule that matched. See 403 Forbidden
Network tab shows 500 or the request returns an error pageA PHP error in a plugin, a theme function or a custom snippet that hooks into the cartRead the error in WooCommerce > Status > Logs (fatal-errors) or the host's error log, and fix or remove the code it names. See plugin fatal error
Shop page buttons fail, but the single product page works"Enable AJAX add to cart buttons on archives" is on, and the AJAX request fails (cache, firewall or a script error, as above)In WooCommerce > Settings > Products, untick that option as a quick stopgap so the button reloads the page instead, then fix the real cause from the rows above

Check it worked

In a private window, logged out, add one simple product and one product with options from both the shop page and the product page. The cart count should change and the cart page should list both items. Then do the same on a phone, since mobile visitors often get a different cached copy.

What not to do

Most of these take a few minutes once you know which one it is. If you would rather someone else finds and fixes it, that is what the box below is for. Related: WooCommerce checkout not working and No shipping options were found.