> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ecomelixir.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Add to cart is not working

> Diagnose a button that does nothing, adds the wrong item, or only fails on some products

Add to cart failures come from four places: the Shopify product setup, a third-party app, custom code, or the theme. This guide isolates which one before you change anything.

Work through the checks in order and retest after each.

## Start with the product

Most failures are configuration, not code.

| Check | Where |
| - | - |
| Product status is **Active** | Shopify admin, product page |
| Available to the **Online Store** sales channel | Product page, sales channels |
| The selected variant exists and has a price | Product page, variants |
| Inventory is above zero, or **Continue selling when out of stock** is on | Product page, inventory |
| Inventory is assigned to a location that ships to the customer | **Settings → Locations** |
| The product is active in the customer's market | **Settings → Markets** |

If the product fails any of these, the button is behaving correctly and the fix is in Shopify. See [Product shows sold out](/guides/product-showing-as-sold-out).

## Then isolate the cause

<Steps>
  <Step title="Compare editor and live preview">
    Test the same product in the theme editor preview and on the live storefront. A failure in only one points at the editor rather than at your setup.
  </Step>

  <Step title="Test in incognito">
    Open a private window with no extensions. Browser extensions, especially ad and script blockers, break add to cart regularly.
  </Step>

  <Step title="Test another device">
    Try a phone as well as desktop. A failure on only one points at a layout or script problem specific to that breakpoint.
  </Step>

  <Step title="Test a clean theme copy">
    Duplicate the theme, remove your custom code from the copy, and test the same product. If the clean copy works, your custom code is the cause.
  </Step>

  <Step title="Test with apps disabled">
    Disable one suspect app at a time in the test copy and retest. See [App conflicts](/guides/app-conflicts).
  </Step>

  <Step title="Capture the console">
    If it still fails, open the browser console and reproduce the failure. The error text is the fastest route to a fix.
  </Step>
</Steps>

<Tip>
  Change one thing at a time and retest. Disabling three apps at once tells you the group is responsible but not which one.
</Tip>

## Symptoms and likely causes

<AccordionGroup>
  <Accordion title="The button does nothing at all">
    Usually a JavaScript error stopping the handler. Check the console first. Common sources are a cart or upsell app injecting a script, a page builder, and custom JavaScript added to the theme.
  </Accordion>

  <Accordion title="It works on the live store but not in the theme editor preview">
    A known Shopify theme editor behaviour, usually down to Markets. The editor previews a country
    the product is not available in, so the button cannot add. Use the country selector at the top
    of the theme editor to switch to a country the product does sell in, then try again. If it adds
    there, nothing is wrong with your theme or your product.
  </Accordion>

  <Accordion title="The button is greyed out or disabled">
    The theme thinks the variant is unpurchasable. Check inventory, location, and market for that specific variant, not just the product.
  </Accordion>

  <Accordion title="It redirects to the homepage">
    Typically an older theme version conflicting with a newer Shopify or app behavior. Update the theme on a duplicate, see [Updating safely](/guides/update-recovery).
  </Accordion>

  <Accordion title="The wrong variant is added">
    Check that each image is assigned to the intended variant in Shopify, and that variant names match what the theme expects. A subscription, bundle, or product-option app can also rewrite the line item.
  </Accordion>

  <Accordion title="It works on desktop but not mobile">
    Check for an element overlapping the button on small screens, such as a sticky bar or a cookie banner. Test with the sticky add to cart both on and off.
  </Accordion>

  <Accordion title="It only fails for some products">
    That points squarely at product configuration rather than the theme. Compare a working product against a failing one field by field.
  </Accordion>

  <Accordion title="A free gift or bundle is involved">
    Promotion rules can block a line item. Test with a simple cart containing only the qualifying product. See [Free gifts](/guides/free-gifts) and [Upsells](/guides/upsells).
  </Accordion>
</AccordionGroup>

## If it is still not resolved

* The product and variant URL
* Your theme version
* Browser, device, and operating system
* The list of cart, upsell, subscription, and product-option apps installed
* A screenshot of the browser console error


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.