I have a added a table to the database where i want to store data depending on what is in the cart. Let's call this table my_cart_table. Assume that i am selling bicycles, tricycles, cars and trucks. And in my_cart_table i want to store that number of wheels that are in the cart. It's a silly example but please work with me here. So if the cart contains a bicycle and a car my_cart_table should have the cart_id, the nid for the two products and the number of wheels that these products have. In order to achieve this i have to make the calculations every time there is a change in the cart, whether a product is added or deleted or a products quantity is updated. I don't know which hook is best to use. hook_add_to_cart is only called when a product is added to the cart which means it's useless for me when items are deleted or updated in the cart. There is also hook_cart_item but i don't understand when it is called. I thought that it would be called for every item in the cart but when i tried it was only called for one of the items in the cart.
The only way i was able to make this work was to add code to the uc_cart_block in uc_cart.module. I simply added some code that will make these calculations for me every time to block is displayed. This works. But since you are not supposed to write code in the modules and use hooks instead i don't know how to continue. I hope some one has a suggestion. Thanks in advance.