cancel
Showing results for 
Search instead for 
Did you mean: 

Can't add to cart when customer not logged in - Magento 2

Can't add to cart when customer not logged in - Magento 2

When I click on Add to Cart when customer is not logged in nothing happens and clicking on the cart icon afterwards does nothing and there is no number (of item in cart) next to it. However when you subsequently log in the item is in the cart.

 

This has started happening for some reason but I have been unable to fix. Any suggestions?

9 REPLIES

Re: Can't add to cart when customer not logged in - Magento 2

Hi @mntoner,

 

Did you checked your browser console to be sure you don't have javascript errors?

--
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution"

Re: Can't add to cart when customer not logged in - Magento 2

Hi Damian,

 

Yes just checked it. No errors.

Re: Can't add to cart when customer not logged in - Magento 2

Hi @mntoner,

 

Is hard to guess which could be the problem.

Normally you should check the brwoser console or the ajax response to see if everything was OK.

Then, you shoul dcheck the Magento's logs (also the webserver error log) to be sure you don't have backend or database problems.

Without a message or a clue... I don't know. Are you using the default Luma theme? If not, can you try again with that theme?

--
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution"

Re: Can't add to cart when customer not logged in - Magento 2

I'm using a custom theme but tried changing to Luma and found the same problem. The strange thing is there are no reports of errors.

 

I have no clue what's going on or how to fix it. If I cant solve it will have to blitz the installation and start again.

Re: Can't add to cart when customer not logged in - Magento 2

Hi @mntoner,

 

Is there a public URL that you can share for testing?

--
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution"

Re: Can't add to cart when customer not logged in - Magento 2

Re: Can't add to cart when customer not logged in - Magento 2

Hi @mntoner,

 

I can't access. Is loading forever.

--
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution"

Re: Can't add to cart when customer not logged in - Magento 2

Its loading now.

 

But I will have to terminate the AWS instance and reinstall if I dont have a solution by tomorrow.

Re: Can't add to cart when customer not logged in - Magento 2

In conclusion.

Turns out that it was a theme related issue after all. I had the following in the default_head_blocks.xml

 

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <script src="js/jquery.min.1.7.js" />
    </head>
</page>

This caused the cart to malfunction.