It's a shop where you can buy drinks. For every bottle/can there has to be an extra item with bottle/can deposit visible to the user.
So for this I added the cans and the deposit as single items. Every can has 3 attributes for the packaging unit of the tray: 6x250ml (default), 12x250ml, 24x250ml.
After that I added a product kit with 1x "can tray 6x250ml" and 6x deposit. This works fine. But if the user selects 1x "12x250ml" the deposit will just calculates the normal 6x.
Now I thought about manipulating the cart before it is visible to the user. For example: Take the quantity of the item, calculate the deposit by the checked packaging unit and multiply by the item quantity. The calculation is pretty simple.
What function/hook can I use to do this?
I tried to deal with
hook_uc_cart_item_presave($entity) but it seems, that the function gets triggered once for every product in the product kit. I can't find a solution to check the quantity on the main item as well as the checked attribute and then pass it to the second run for the deposit item.