It appears that the "add to cart" button does not work for panels pages served to anonymous users when using Varnish.
I have a website running Commerce 1.x-dev (2013-Jul-21) on Pantheon, which automatically enables Varnish for Drupal. I've tried both the latest stable versions of Entity, Ctools, and Commerce as well as the latest dev versions of the same.
The problem appears to be limited to Varnish because I develop locally using MAMP on Apache and I experience no issues. When I export the database from Pantheon into MAMP, I do not have the problem.
How to reproduce:
1. Visit http://test.npp.gotpantheon.com/store/buy-japanese-psn-cards.html
2. Click any of the "Add to cart" links on this panel. The first set "Buy Sony PSN Japan Codes Now" is a content pane. The second set "Sony Japan PSN 3000 yen code" is a rendering of a product display node through Panels. The third set (second "Buy Sony PSN Japan Codes Now") is a view page being rendered through panels. None of these work.
However, by visiting a product display node (or view page) and clicking the add to cart link, products can be added to the cart:
http://test.npp.gotpantheon.com/store/codes/sony-japan-psn-3000-yen-code
The standard views page display (not using Panels) works as well:
http://test.npp.gotpantheon.com/store/psn
And strangely, once you have added a product to the cart using the product display node, you can then go back to the panel (http://test.npp.gotpantheon.com/store/buy-japanese-psn-cards.html) and add products to the cart using any of the links.
However, if you clear your browser's cache and go back to the panel, you cannot add products to the cart-- until you first add a product from the product display node (or view page).
So, it appears that the "Add to Cart" link, when rendered using Views inside Panels, does not work for anonymous users when the site is being served using Varnish.
EDIT: I also tried this with the just-released 1.8. No change in behavior.
Comments
Comment #0.0
ptmkenny commentedadded correct link
Comment #1
rszrama commentedThe issue is caching; once you add a product to the cart (whatever it is), you get a session, which bypasses the Varnish cache for future page requests. The initial request is just using stale form HTML. I think I'm going to mark this a duplicate of #2049665: Provide a way to generate Add to Cart forms asynchronously to support page caching, which started with a similar scenario using Drupal's built-in page caching.
Comment #2
ptmkenny commentedThanks for the fast response. I doubled-checked my Panels settings and confirmed that the caching is disabled for the panels in question.
So, here is a summary of the situation:
* Varnish is applied to the whole site.
* The "Add to Cart" link works on individual product display pages and Views pages.
* The "Add to Cart" link does not work on "Add to Cart" links on Panels pages unless something has already been added to the cart on a different page
This doesn't seem to be a caching issue to me but rather a Panels issue (since Views works, but not Panels). Of course I'm willing to accept your judgment as maintainer though; I'd just like to confirm.
Comment #3
rszrama commentedVarnish is a cache, so you're still dealing with stale form HTML, no?
Comment #3.0
rszrama commented1.8 note
Comment #4
PI_Ron commentedWas this issue ever resolved? I'm experiencing it with a Panels page and add to cart links not refreshing shopping cart block.