First, I like the new AJAXified cart block.. nice! But it seems one of the other features I liked best about the previous versions of Ajax Cart, is that it had a very low profile to the end user. The LightBox2 type notifications and the Growl Window messages really intrude on the user.

I would like to see a third status notification added back in, the original type where the Add to Cart buttom would cycle until the product was added to the cart. This was great, in that the customer knew what was going on, without sections of their screen going into fits.

Thanks!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

wbclassics’s picture

Just a quick addition to my previous comments. Drupal Commerce (the D7 fork of Ubercart) has a fairly tame status updater for their built in ajax cart. Just a simple "green" box that loads on the node product page, when the product has been successfully added to the cart.

Drupal Commerce demo: https://dc-demo.dev.c--g.net/

Erik Seifert’s picture

But it is no ajax cart. So i hope this module will survive ;- )

wbclassics’s picture

Oh definitely, I don't want this project to go away! But come time to work in D7, I'm going to have make a choice between Ubercart or Drupal Commerce.

I love UC Ajax Cart, but since one of my reasons for using it is to keep the customer focused on the category/product content, I have to use 6.x-1.0 for right now because 2.0-beta2 is too disruptive to the user IMHO. A quick, simple, low key confirmation on successful product addition to the cart should be an option.

sirleech’s picture

Version: » 6.x-2.x-dev

Agreed, I don't like the Popup notifications. Here is a good example of a simple, non-intrusive notification of addition to cart:

Ajax Cart Example
http://www.sparkfun.com/categories/new_products

tunic’s picture

I guess it's a fair feature request, but now we are focused a stable version, so I preffer to not include this new feature in the current Current Candidate cycle, this will have to wait for 2.1.

What way could be fine?

1) Add some kond of message near add to cart button or product node markup (as #4 example).
This solution implies more work theming. becasue generated markup may no fit theme.

2) Add a message in the cart block itself, may be in last line.
This is more theme indepenent.

3) Generate custom JS events and let site builders create a custom notification.

4) Use Drupal message system. I don't if it's simple to generate a Drupal message using Ajax an insert it in page via AJAX. Any help?

Ah, Drupal Commerce example is not Ajax, so it just uses drupal_set_message to display cart operation.

Any other ideas?

sirleech’s picture

Personally I feel option (1) is the most usable solution. Imagine a long list of products, and when using option (2), no feed back is shown if your cart block is on the top of the page.

However, the theming may be an issue :)

hanoii’s picture

Related to #1213574-9: Ajax Cart not working with uc_out_of_stock notification, only because of the status messages problem I reported there.

I had to look into this yesterday and I do have some comments and ideas.

Personally I think a combination of all of the ideas on #5 should be fine, except maybe 2).

One thing I noticed is that the status messages are hardcoded into the module, which means that no matter what the sites reported, such as out of stock message my the third-party module (I am the maintainer) reported in the previous issue, are not really taken into consideration, so this needs a bit of a wider change. Somehow, status messages generated on the site should be sent back to the server on the ajaxCall. So instead of doing the the message thing on the beforeSubmit, it should be done after submit and display whatever messages comes from the server. I believe this is not hard to do.

Then we have the issue on how to present the error messages to the client. Adding some kind of message near the add to cart button is, for me, the nicest approach and although it might require some theming, it may not be that much and if so, it's like theming any other bit of code. This can all be bundled on theme functions that can be overriden. Even if the theme is done on JS, it can be overriden as well using Drupal.theme.prototype approach, but I don't even think this is necessary.

This, however, may doesn't fit nicely with status messages, as they can be one or more and they can be long. So I would still do this with something standard like: "Product added successfully" and "Product cannot be added" and also do 4).

4) (display status messages from JS) is a tricky one. Yes, you can add anything on the DOM so eventually you could add status messages but the problem is you never really know where. I would do it in standard way and target #messages which is the standard div on drupal themes that contain messages. The problem is that normally, when there are no status messages , this div is not even there, so one change is to make the themes add it on the site.

We have to also provide a way for some kind of override so a themer can do anything they want with the status messages. There are a lot of ways of doing this, I would think of doing something similar on how Drupal.theme.prototype works. So you could define a Drupal.uc_ajax_cart.message.prototype and allow other module or theme developers to define other Drupal.uc_ajax_cart.message and trigger those if available.

I am sorry to have made this a long issue but wanted to share my ideas. I don't think I will have to actually work on this for a client of mine right now, if I do I will let you know, but I don't want to lose my thoughts.

hanoii’s picture

Something of what I said above is wrong. There are actually error messages coming from the server (a.k.a. out of stock messages) and they are shown.

Attached is a patch that takes some of what I said and move things one step forward.

It's not a small patch and I took the liberty to do a few things:

- Removed the title from the popups (there were really no point on having those, messages are slicker with just the enough content.
- Added throbber.gif and throbber classes. This again makes a bit slicker as it gives the impression that something is going on. Also slightly changed some of the messages to give the idea of a continuing action, like: "Adding products to the cart..." instead of "Add products to cart". Note: the throbber works only on blockui, growllike styling with black background was odd so I only apply it to the blockui, but it can be themed w/o any issues if necessary with a new/different throbber.
- Removed a bunch of functions that were not used or made no sense to have them.
- And the most important/useful thing of all is the use of Drupal.theme('ajaxCartMessage', message) approach rather than the previous internal function. It is very similar to what was before, minus the titles, but this allows any themer/developer to override the function on their theme's JS and therefor do anything they want with the message (display it differently, etc.).

NOTE: please apply this patch with git apply, otherwise the files will be properly patched but you will miss the throbber.gif file.

I will attach it here just in case, is the standard drupal throbber.

hanoii’s picture

worth saying there's quite a bit of work to do, but again, I do feel is helpful

tunic’s picture

Assigned: Unassigned » tunic
Status: Active » Needs review

This patch looks very good, is very helpful indeed. I like the idea of using Drupal.theme, nice work.

I haven't tested yet but I'll do ASAP.

Thank very much for your work, this is a big help fort this module!

hanoii’s picture

Very small change to the patch above, any follow up on this one?

tunic’s picture

hi hanoii, thanks for your new patch. I've tested it and seems to work ok, but I want to test it with some installations that uses title, because title removal may be an issue for sites that are using it. It may be interesting to make title optional. I need some time for test it, sorry for not having time but I'm really short of it.

stewart.adam’s picture

I *really* like this idea and the patch looks great. I've recently inherited this module so I'm working on some critical bugs (broken compatibility with 2.7+) but will look at getting this committed after that.

In the mean time, if any users want to test this and can confirm it works please mark as RTBC as it will help to get this committed more quickly.

stewart.adam’s picture

Issue tags: +6.x-2.2 blocker

Tagging for 6.x-2.2 blocker.

stewart.adam’s picture

Status: Needs review » Fixed

Committed to git (along with some additional refactorings). Thanks for the patch, it should appear in a dev release within 24h.

Status: Fixed » Closed (fixed)
Issue tags: -6.x-2.2 blocker

Automatically closed -- issue fixed for 2 weeks with no activity.