I want to write some code as an reaction to a product being added to the cart.
To my surprise it seems it's only possible to react if a user tries to add a product to cart, and not if it actually succeeded.
In my use case, I want to add some tracking on the site when users add an item to the cart, so it makes a big difference if the product is actually added, or only is attempted to be added.
Maybe it's just me that overlooked something, but going through the uc_cart_add_item function, I couldn't see how this would be possible. I figured this would be a pretty standard request, to act on products being added, so maybe I'm missing something?
Comments
Comment #1
longwaveIf you want to propose the name of the hook, and maybe even add a patch to uc_cart that invokes it, that would be helpful in getting this added.
Comment #2
alanmackenzie commentedI've attached a patch for the 6.x-2 dev branch that adds hook_uc_cart_modified($op, $cart_item_id, $qty, $data).
Explanation of Parameters:
Here is an example implementation of hook_uc_cart_modified():
Feedback welcome, particularly on the name of the hook and whether the $cart_item_id parameter should just be a full $item object.
I'm also willing to write a D7 version of the patch just let me know and I'll do it.
Comment #3
alanmackenzie commentedstatus update.
Comment #5
tr commentedFeature requests should be made against HEAD.
I'd greatly prefer to address this in the current version of Ubercart first (7.x-3.x).
Comment #6
longwaveThis will be fixed in 7.x-3.x by #1492626: "Cart Items" triggers dont work
Comment #7
longwaveNo new features are being added to 6.x-2.x, as per #1903564: [policy] Maintenance phase for 6.x-2.x branch