Closed (fixed)
Project:
Ubercart
Version:
6.x-2.x-dev
Component:
Documentation
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
29 Jul 2008 at 09:57 UTC
Updated:
20 Dec 2011 at 00:36 UTC
I - and others - would like to see that hook_cart_display() will be invoked for all modules and not just for those that provide a product type.
Comments
Comment #1
xanoComment #2
Island Usurper commentedI don't think this is something that will happen any time soon. Sorry.
Comment #3
xanoComment #4
rszrama commentedWould need a good rationale for this for it to be considered for UC 3.x. Please don't move it from postponed if you add any info.
Comment #5
xanoWell, there's a simple reason for allowing all modules to intercept the cart display: why prevent it? Don't put limitations on your software unless it's necessary. There are dozens of maintainers that would like their contribs to modify the cart display to add or alter features, but because those modules don't offer a product type themselves this is impossible.
Comment #6
Island Usurper commentedhook_cart_display() is called for each item in the cart, and each particular item's module gets to decide what it looks like in the cart. It's really more of a callback with a standardized name than a hook that's used with module_invoke_all(). This is the way the node hooks like hook_view() and hook_insert() work. Only modules that have a node type (defined in hook_node_info()) actually implement hook_insert(), but if any other module wants to modify what gets inserted, it needs to use hook_nodeapi('insert').
You can change how the cart looks from any module already with hook_form_alter(), since all the data is put into the form building function. Take a look at the TAPIr documentation, since that's heavily involved in the construction of the form.
I don't want to change the fact that only products can be added to the cart. That lets Ubercart assume that data like price, sku, etc. are available to use. That's what I thought you were asking for at first, which is why reacted so strongly. Changing the way the cart looks after hook_cart_display() is used is the way to go.
Comment #7
ckidowA tip I've got from "longwave" in irc:
And it just worked.
Big THX to the Drupal Community!
Comment #8
joachim commented> It's really more of a callback with a standardized name than a hook that's used with module_invoke_all().
That's fair enough.
But the documentation does not make this clear and should be changed.
http://api.ubercart.org/api/function/hook_cart_display/2
Comment #9
rszrama commentedComment #10
Island Usurper commentedAnd just so we don't forget, http://www.ubercart.org/docs/api/hook_cart_display should also be updated.
Comment #11
Island Usurper commentedSzrama!!!!
Comment #12
rszrama commentedMantooooOOOOooooth!!! >: )
Comment #13
Pierco commentedIf you want to alter the cart display, use hook_tapir_table_alter() and check $table_id = "uc_cart_view_table":
http://api.ubercart.org/api/function/hook_tapir_table_alter/2
Comment #14
japanitrat commentedwhy is that? It's a fairly minimal change in code, just replace the module_invoke with module_invoke_all?
Edit: nevermind, just read the whole thread --
Comment #15
longwaveAt long last, improved in both branches by adding two lines to the API documentation. Also changed the reference from "checkbox" to "submit" in the same docs, since we switched the method of removing items from the cart.