Closed (fixed)
Project:
Ubercart
Version:
6.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
30 Apr 2009 at 00:29 UTC
Updated:
5 Nov 2011 at 07:40 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
plousia commentedYeah, I'm running into this issue too. I got called in to fix this problem in a site which is running this version of Ubercart. Even though the "hide block if cart is empty" option is checked, when you go to the cart settings in store configuration (admin/store/settings/cart), it says "Cart block is shown when empty." The empty block is not shown to logged-in users, only to anonymous users.
Comment #2
Island Usurper commentedThe Cart settings overview is just using the wrong variable name for the cart visibility message. That's easily fixed with the attached patch.
Do you have page caching turned on? That's the only way I can find that keeps the block visible when the setting is turned on. I kind of feel like that's the way it should work since the whole point of caching is to serve the same content to as many people as possible.
Comment #3
Island Usurper commentedI committed the patch, since it's just a display issue.
Comment #4
butler360 commentedSo there's no way to make this work with page caching enabled?
Comment #5
keva commentedWhat does the patch fix?
Using Drupal 6.11 and RC2 with the patch, and the cart block still shows up for anonymous users.
These are checked in the block settings:
X Hide block if cart is empty.
X Display the shopping cart icon in the block title.
(no role specific visibility settings are checked).
Comment #6
escoles commentedI believe that this and http://drupal.org/node/377798 are almost duplicates.
I see the behavior described here, and on the site I'm concerned with the issues seems to be clearly w/ page caching. Turn off normal mode page caching, and the block will behave as expected.
Note that normal mode page caching seems to be sufficient. Neither block caching nor aggressive mode page caching are required to trigger this block visibility issue.
I would argue that this calls at least for clearer documentation on the Performance page of the compatibility issue. Currently, the warning states that uc_cart is not compatible with aggressive caching, when normal caching is sufficient.
Comment #7
josi123 commentedI also can't get the "hide block if cart is empty" option working. Normal caching enabled. Anonymous users always sees empty cart.
I think normal caching is what most sites uses so why is this still a bug? Do we just stop using the cart block?
Comment #8
Island Usurper commentedDid you turn on that setting after you enabled page caching? Your users are probably still seeing the cached page.
Comment #9
josi123 commented#8 Yes. But the issue remains even after clearing all caches. Is there any way to get this thing working?
Comment #10
mautumn commentedSubscribing
Comment #11
JennySmith commentedI, too, am experiencing this bug with normal caching set.
Could this be fixed with some PHP code in the block configuration? I couldn't begin to write it myself, but perhaps there's a way to control the behavior of the block outside the ubercart code.
Comment #12
mr.andrey commentedsubscribing... experiencing the same behavior
Comment #13
babbage commentedSame problem; definitely a bug.
Sounds like the argument is being made that the empty cart should be shown to people as it means cached pages can be shown to as many people as possible. That doesn't make any logical sense at all since a page without an empty Ubercart cart is obviously at least as easy to cache as a page that has an empty one.
Comment #14
mrandy commentedsame here as well.
Comment #16
butler360 commentedNice spam from nan-dini. I'm setting the title back to what it was.
Comment #17
babbage commentedComment #18
jpstokes commentedI'm also experiencing the same problem. I found that when you disable caching all together it works as expected. So it definitely has something to do with the caching. Hopefully the maintainer comes out with a fix for this.
Comment #19
johnflower commentedI'm in the same boat. Hide the block if the cart is empty, PLEASE!
Comment #20
echoz commented+1 for being able to hide cart if empty for anonymous users, with page caching on.
Comment #22
jpstokes commentedComment #23
petey318 commentedSubscribing
Comment #24
toddgee commentedsubscribing on a Summer day in Spring. Nature's April Fools Day joke on Chicago.
Comment #26
Fienix commentedSubscribing
Comment #27
marcushenningsen commentedI can confirm that disabling caching makes it work.
Marcus
Comment #28
jsenich commentedMe too. Works if caching is disabled. Does anybody have a quick fix for this?
Comment #29
josi123 commentedNo fix after all this time... too bad, one of the reasons why I removed ubercart module
Comment #30
royerd commentedSurely this will get fixed . . . ?
We don't want anonymous users seeing an empty shopping cart. We want the anon user to be treated just like the authenticated user: if the cart is empty, hide it; if the cart has items, show it. Otherwise, what's the point of "hide shopping cart if empty"?
Dan
Comment #31
tr commented... which is the fundamental problem, because DRUPAL page caching does NOT treat anonymous users the same as authenticated users. If you want to treat anonymous users the same as authenticated users in DRUPAL you need to turn off page caching. Period. Page caching is done only for anonymous users (pages presented to authenticated users are not cached) and with page caching on DRUPAL treats all anonymous users as if they were one, and will show them all the exact same page.
Comment #32
royerd commentedAh, I see. Makes sense.
Comment #33
freixas commentedIt seems as though this bug should be closed—as far as I can tell, there is no bug (as explained by TR in #31).
If page caching is enabled, the block content is different. It always says "View your cart" regardless of whether the cart is empty or not. This is a appears to be a deliberate design decision since it's the best you can do with page caching enabled.
As TR said, if you want anonymous users to view the cart just like authorized users, turn off page caching.
In my case, I have redundant "View cart" and "Checkout" buttons on every page, so I added the following PHP code to the "Page specific visibility settings":
return user_is_logged_in();If you are not logged in, the block will not display. You will need to use the redundant "View cart" or "Checkout" buttons. If you are logged in and the cart is empty, the block will not display. If you have items in your cart, it will.
Comment #34
butler360 commentedHas anyone tried this?: http://drupal.org/project/ajaxblocks
I might when I get some time later.
Comment #35
mikesir87 commentedNot sure if this anyone wants to use it, but this works as well... paste this into the block display settings, using the PHP option...
Comment #36
escoles commentedTo be clear, the only way this is not a bug is if the block feature is designed explicitly to work this way.
Put another way: Unless the documentation clearly states that this block does not honor block caching, then this is a bug.
If the block does not honor block caching, and that's not documented, this is a bug.
Comment #37
johnflower commented*bump*
Comment #38
Starminder commentedsubscribe
#35 works great, except you have to refresh the page to make the cart visible.
Comment #39
torgospizzaHave you tried the patch available here? #886148: Empty shopping cart block visible to anonymous users
Comment #40
allanp commentedHas anyone been able to hide an empty cart for anonymous users without disabling normal caching?
Comment #41
interestingaftermath commentedsubscribing because I would also like to know an answer.
Comment #42
torgospizzaHave either of you tried the patch I linked to in #39?
To clarify, that patch seems to work with Block caching disabled, but it appears to still work without disabling the regular caching. I don't believe there's any workaround, at this time, to show the right block with block caching enabled, unless you're using Ajaxify Regions or some other method of showing the cart block via Ajax.
Comment #44
allanp commented@torgosPizza: Finally able to get the patch you referenced in #39 to work.
Thank you for pointing out the other thread.
Comment #45
torgospizza@allanp: Glad to hear it! Did you have to do anything special to get it to work? Please let us know, so others in the thread can benefit :)
Comment #46
longwaveSo, what can we do to fix this? There seem to be two options:
The first one changes existing behaviour, which may not be required for all sites. But the second means the option actually does what it says... comments welcome, and whichever one gains consensus I will try to roll a patch for.
Comment #47
tr commentedA third option would be to make the cart block content always load via Ajax, to avoid the caching issue altogether? If "hide block if empty" were checked, the script making the Ajax request would hide the block based on the server's response.
Comment #48
longwavePossible approach to the anonymous cache issue: http://drupal.org/node/875152
Comment #49
jnettikSubscribe
Comment #50
jlancaster commentedSame problem. Since this used to work, this seems more like a bug to me!
BTW, mikesir87's code above works for hiding it in the block display settings.
Comment #51
haggins commentedsubscribing
Comment #52
Gaperville commentedPatch didn't work using D7.8 w/ Uber 7.x3.0-rc2.
Weird how this issue is still going on after all these years!
Cache is disabled too. After clearing the cache i get an error message form the patch of:
Parse error: syntax error, unexpected T_IS_IDENTICAL in /sites/all/modules/ubercart/uc_attribute/uc_attribute.admin.inc on line 1354
Comment #53
tr commentedOf course the patch didn't work with UC 7.x-3.x, this is a Drupal 6 issue and patch.
Comment #55
butler360 commentedUh...
Anyways, he did not close the issue, just returned it to how it was before you changed it. No one knows the solution, otherwise this would be marked as fixed.
I would recommend against language and behavior like that unless you want to be banned.
Comment #56
longwaveGaperville's abusive comments aside, this should be fixed in 7.x-3.x-dev by #1285818: Remove uc_cart_exit() and cache-safe cart block - unfortunately the same approach does not apply in Drupal 6, so this issue remains open.
Comment #57
Gaperville commentedYes Sir!!!! Thanks for the Love and Support!
Comment #58
longwaveAttached patch adds help text as follows to the checkbox, explaining the current behaviour:
I think this is the only way to solve this without an Ajax cart. When page caching is enabled, Drupal serves the same page to all anonymous users whether or not they have items in their cart. For consistency we should show the same "Click to show cart contents" block here, otherwise the block may randomly appear and disappear between pages, depending on if the first viewer of the page has items in their cart or not. There is no way around this with page caching enabled.
Comment #59
longwaveComment #60
longwaveCommitted #59. As explained above I don't see any other option here except an Ajax cart.