Tags/topics: 
1
Answers
Vote up!
0
Vote down!

Cannot add product to cart for anonymous users via "add to cart" link in Views with Panels and Varnish

I may not have isolated the root cause of this issue but I have done my best to trace this problem.

I have a website running Commerce 1.x-dev (2013-Jul-21) on Pantheon, which automatically enables Varnish for Drupal. I am experiencing a strange issue in which anonymous users are not able to add products to their carts using the "add to cart" link when provided in a view. Clicking the link simply does nothing. Authenticated users are able to add products to their carts fine.

Further, this problem only occurs on Pantheon (nginx where Varnish is enabled and it is impossible to disable Varnish). I develop locally using MAMP on Apache and I experience no issues. When I export the database from Pantheon (where anonymous users cannot add products to the cart) and import into MAMP, I do not have the problem, so I am tentatively blaming Varnish.

Steps to reproduce:
1. Try to add a product here (my test server):
http://test.npp.gotpantheon.com/store/buy-japanese-psn-cards.html
The shopping cart block on the left will be empty.

However, it is possible to add a product here:
http://test.npp.gotpantheon.com/store/codes/itunes-japan-3000-yen-code

The first page (that doesn't work) is a Panel containing a view (content pane) that shows nodes of content type product display, which have a relationship to their products and the "Add to Cart" link displayed in a field.

The second page (that does work) is the normal display mode of the product display content type.

I created a View page and attempted to add products there; I was able to add the products. I then added this View page to my panel and I could not add the products. I also added a product display node directly to the panel; this did not work, either.

So, it appears that the "Add to Cart" link, when added in Views inside Panels, does not work for anonymous users when the site is being served using Varnish. However, the link will work if you first use one of the "add to cart" links on a node (not a view) and then go back to the view page and attempt to add a product. Still, if I reset the browser (clear all caches, cookies, etc.), then the views "add to cart" link will no longer work until a "add to cart" link on a node is clicked first.

EDIT: Since I think I have identified the problem (Panels/Commerce), I posted an issue on drupal.org:
https://drupal.org/node/2049913

Asked by: ptmkenny
on July 23, 2013

1 Answer

Vote up!
0
Vote down!

I'm not sure this actually qualifies as an answer... but perhaps there's tips in this tutorial? It's what I used to have my webshop become available to anonymous users.

Then again, I suppose you've already done that if you've gotten this far.

Answer by: zJoriz
Posted: Jul 24, 2013