In my Drupal installation I also have a small block in the header where a customer can see how many items there are in the cart and the total order amount. (You can see this in attachment)

Now, I want that this block is updatet when a user add something to it's cart. What should I do to accomplish that?

CommentFileSizeAuthor
cart.PNG4.86 KBufeg02

Comments

tunic’s picture

Assigned: Unassigned » tunic

Not easy solution right now. Best solution would be that UC Ajax Cart fires a JS event when Cart is updated (well, when some operation is done on the cart, not when cart info is retrieved). Then you only have to hook on this event (write a JS handler) and make changes on your block accordingly.

Unfortunately UC Ajax Cart doesn't fire that kind of event, but I guess I can be easily added; I''l check that.

For the record, I think event firing should be added in ajaxCartFormSubmitted JS function.

tunic’s picture

Status: Active » Postponed

I guess makes sense to add custom qjuery events, but I think that they must be added for all actions, not just update. This needs some work, so I'm postponing this usse for the moment.

stewart.adam’s picture

Status: Postponed » Fixed

uc_ajax_cart now uses attachBehaviors() to notify other modules when it changes the DOM. You can have your module implement Drupal.behaviors in order to react to the change. Be sure to check the context variable to ensure that the content changed was indeed the ajax cart before making adjustments to your block. For details, see http://api.drupal.org/api/drupal/developer!topics!javascript_startup_gui...

Status: Fixed » Closed (fixed)

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