Needs work
Project:
Ubercart
Version:
8.x-4.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
16 Jan 2010 at 16:42 UTC
Updated:
5 Apr 2018 at 02:58 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
peximo commentedops sorry.
Comment #2
tr commentedThe patch doesn't work when the product is added to the cart using a cart link. Try using hook_cart_item() instead of the form validation function.
Comment #3
gapa commentedI create this function in my module:
Can anyone tell me how to display empty cart and put this message into cart page. At the moment I only get empty page with this message.
br,
gapa
Comment #4
tr commentedTry drupal_goto('cart'); instead of your print theme_status_message('error');
I'm not even sure you need the drupal_goto() - if you just let it exit instead of printing then you should be redirected to the cart page anyway I would think.
Comment #5
gapa commentedIf I use drupal_goto() I get cart page, but I would also like to display this error message in this cart page. So I would like to combine cart page (empty) and this error message. Can this be done?
br,
Gapa
Comment #6
adamo commentedSubscribing.
Comment #7
adamo commentedUltimately I think Ubercart needs to be patched to check for cookies when adding items to a cart, whether that is being done via an add to cart form, or a cart link.
For now on my own site I have worked around this by implementing theme_uc_empty_cart() in my themes template.php. Both the error message and empty cart page will be displayed doing it this way, and the code will only be executed once when the actual cart page is displayed. This is certainly not a good permanent solution but as a temporary fix it works fine for me. My function in template.php looks like this:
Comment #8
tr commentedDoes *Drupal* even work if cookies are disabled? I don't think so, and I recall a long-open issue asking for Drupal to check for cookies and present an informational message if the user didn't have cookies enabled. If my recollection is correct, I think that is the way to go - this should be addressed in Drupal rather than Ubercart.
Comment #9
adamo commentedDrupal works without cookies. Nothing that requires a session will work, but anonymous stuff works just fine.
There is an open issue trying to get a cookie check added to Drupal that will display a warning if a user tries to log in without cookies: #2946: Login fails and no warning is issued if cookies are not enabled
It's like 7 years old.
There is also a module for D6 that provides the same functionality as the proposed patch would.
http://drupal.org/project/cookie_check
Both of these things affect login only. I think that's the right way to go, since you don't necessarily want your entire site to be unavailable just because someone has cookies disabled.
Ubercart doesn't require you to log in before you add items to your cart (nor should it). Currently if someone who has cookies disabled tries to add something to their cart, they get taken to an empty cart page. To the average user who doesn't really understand what cookies are it's probably going to look like the site is just plain broken. Even if one of the above solutions is implemented, an anonymous user with cookies disabled who tries to add something to their cart is simply going to get back an empty cart page. Not good, especially since people new to your site are likely to browse around your catalog and see if you have anything they want before they even bother creating an account. I know when I shop around I'll browse a site and add a bunch of stuff to my cart and see what it's all going to cost me, before I bother creating an account on the site. Anonymous users should be able to add stuff to their cart, and if they are unable to because they have cookies disabled, the site should let them know that so they can enable them.
Comment #10
tr commented@adamo: Thanks for looking that up - I knew I had seen it somewhere ...
So it sounds like having Ubercart check for cookies on add-to-cart and display a message if cookies aren't enabled is the right thing to do.
Comment #11
SeanA commentedCan we put the cookie check in theme_uc_empty_cart() like #7? I'm not understanding why this isn't a good solution, it seems to work just fine. I changed the message somewhat.
Comment #12
tr commentedThis sort of check shouldn't be performed in the theme layer. Sites are allowed to (even expected to!) override the theme functions.
Comment #13
tr commentedThis sort of check shouldn't be performed in the theme layer. Sites are allowed to (even expected to!) override the theme functions.
Comment #14
Rainman commented#7 as presented as a theme override in the template.php, it does work as expected and is a reasonable workaround for now.
hoping to see a proper solution in Ubercart.
Comment #15
tr commentedNew features go in to 7.x-3.x first. Please submit a patch if you'd like to see this put into Ubercart.
Comment #16
tr commented