Per Ryan's request, I'm adding this to the issue tracker here.

I've created a patch that implements a 'remove' operation to hook_cart_item().

As Ryan suggested, this patch should cause items to be removed from the cart one at a time rather than dumping the whole thing with a single db_query(). This would ensure that any modules that perform actions on removal of items get that chance when the cart is emptied, rather than only when a single item is removed.

This patch needs review.

Comments

Island Usurper’s picture

StatusFileSize
new1.42 KB

On the order complete page, it looks like the items are still in the cart, which should look empty by that point. This is caused by the call to uc_cart_get_contents() in uc_cart_empty() because it caches its results in a static variable. The cart block calls that function again before the next page load, so the customer can see their old cart.

Here's a new patch that resets the cart cache after it is emptied.

mikey_p’s picture

Subscribing

mikey_p’s picture

Status: Needs review » Reviewed & tested by the community

This seems to work as advertised, I'm trying to do some work with conditional actions operating on nodes as they are added to and removed from a cart, and have implemented a hook as seen below, and it seems to work as expected:


function uc_cart_triggers_cart_item($op, &$item) {
  if ($op == 'remove') {
    $node = node_load($item->nid);
    ca_pull_trigger('uc_cart_triggers_cart_remove_item', $node);
  }
}

Island Usurper’s picture

Status: Reviewed & tested by the community » Fixed

Good to hear. Committed.

Status: Fixed » Closed (fixed)

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