Jump to content

Add to Cart not working in 1.5


Recommended Posts

I have upgraded from 1.4 to 1.5. In the old version when add to cart was clicked the cart appeard with the product showing and the account registration form below.

 

Now nothing appears to happen when the add to cart is clicked, but the product is added in background and can be seen with the form below by clicking the cart (empty) link on the top of the site. Very confusing for users. Many will click several times - then give up without clicking the cart (empty).

 

Any help would be appreciated.

Link to comment
Share on other sites

I have this as well, a critical bug I'd say ... my cart is in the RHS column and when adding to cart Ajax fails and it goes to the checkout without adding the item ...

 

Update: For me this bug is strangely erratic, is currently only happening on one computer on latest Firefox version where as other computers are ok. Have cleared cache, turned off cache in Prestashop, enabled multishop etc etc to no avail.

Edited by netmechanics (see edit history)
Link to comment
Share on other sites

  • 4 weeks later...
  • 3 months later...

i have same problem when i uninstall module it change position of hook module.Nothing of this is good,same tamplate on 1.47 with same configuration is working well in 1.5.3.1 product is not shown in chart when i refresh page he is in chart.This new wersion is realy not good.there is also bug with transation my question is why you dont solve that

Link to comment
Share on other sites

This bug can be resolved by un-hook the module block cart from the hook Top of pages.

Go to You BO in Modules >> Position then go to the bottom of the page and unhook the module.

The problem will be resolved. I'v just make the test.

Link to comment
Share on other sites

I had the same issue with 1.5.3.1 and investigated till I found the root cause which is a tricky cookie issue. I also added this to the issue http://forge.prestas...owse/PSCFV-7952

 

 

When I use firefox with httpfox and check the cookies then I notice two almost identical cookies. The cookie key is exactly identical. But one is mentioned for domain .mydomain.com and the other for .www.mydomain.com

 

The URL I use is www.mydomain.com and also the ajax requests goes to www.mydomain.com

 

When I print_r($_COOKIE); then I see only one of the two. I also discovered that FrontController.php init() does not see that there is a cart id in the cookie when pressing ADD TO CART. So every time I click ADD TO CART is does do an ajax call back and generated a new cart as it thinks it does not exist. I see also new records generated in ps_cart with the same id_guest.

 

The cookie I see in PHP with print_r($_COOKIE); (I write it to a file to not disturb the ajax) is the one of the .mydomain.com domain. AND I can see that after the ajax call it sets the .www.mydomain.com cookie.

 

And when I click CHECKOUT then it display that the cart is empty.

 

So actually the root cause is related to the cookie. I reads cookie of .mydomain.com and writes cookie of .www.mydomain.com

 

 

Then I found a work around!

 

With this change I make the cookie name also depending on the domain. So it will not give the same cookie name for both .mydomain.com and .www.mydomain.com as this caused PHP to confuse which cookie to use.

 

In classes/cookie.php function init()

 

you see

$this->name = md5(_PS_VERSION.$name);

and later

$this->_domain = $this->getDomain($shared_urls);

 

The change is to move the line starting with $this->_domain above the line starting with $this->_name and then add the domain to the name like this:

$this->_domain = $this->getDomain($shared_urls);
$this->name = md5(_PS_VERSION.$name.$this->_domain );

Now each cookie name is depending on the name and will not conflict. It directly solved my issue properly.

  • Like 1
Link to comment
Share on other sites

  • 2 months later...

I had the same issue with 1.5.3.1 and investigated till I found the root cause which is a tricky cookie issue. I also added this to the issue http://forge.prestas...owse/PSCFV-7952

 

 

When I use firefox with httpfox and check the cookies then I notice two almost identical cookies. The cookie key is exactly identical. But one is mentioned for domain .mydomain.com and the other for .www.mydomain.com

 

The URL I use is www.mydomain.com and also the ajax requests goes to www.mydomain.com

 

When I print_r($_COOKIE); then I see only one of the two. I also discovered that FrontController.php init() does not see that there is a cart id in the cookie when pressing ADD TO CART. So every time I click ADD TO CART is does do an ajax call back and generated a new cart as it thinks it does not exist. I see also new records generated in ps_cart with the same id_guest.

 

The cookie I see in PHP with print_r($_COOKIE); (I write it to a file to not disturb the ajax) is the one of the .mydomain.com domain. AND I can see that after the ajax call it sets the .www.mydomain.com cookie.

 

And when I click CHECKOUT then it display that the cart is empty.

 

So actually the root cause is related to the cookie. I reads cookie of .mydomain.com and writes cookie of .www.mydomain.com

 

 

Then I found a work around!

 

With this change I make the cookie name also depending on the domain. So it will not give the same cookie name for both .mydomain.com and .www.mydomain.com as this caused PHP to confuse which cookie to use.

 

In classes/cookie.php function init()

 

you see

$this->name = md5(_PS_VERSION.$name);

and later

$this->_domain = $this->getDomain($shared_urls);

 

The change is to move the line starting with $this->_domain above the line starting with $this->_name and then add the domain to the name like this:

$this->_domain = $this->getDomain($shared_urls);
$this->name = md5(_PS_VERSION.$name.$this->_domain );

Now each cookie name is depending on the name and will not conflict. It directly solved my issue properly.

 

Thx for trying to give a solution but it didn't work for me. It still adds the product to the cart through AJAX but when you checkout, the cart is empty.

Edited by gonssal (see edit history)
Link to comment
Share on other sites

  • 5 months later...
×
×
  • Create New...