Hi,
I'm trying to write something that informs the customer that the item they are trying to add to their cart is out of stock, rather than having them get to the shopping basket before they can see what is out of stock.
I have the Stock by Attribute 4.7 mod installed and am running Zen Cart 1.3.8a.

I have it working except that I can't get the number of items already in the basket by attribute.

For example, if I have 3 blue widgets in the cart and 2 red ones, I need a function that I can pass the product ID and the attribute ID and it will pass back the quantity I currently have in the cart.
i.e. 2 or 3.

Is there anything existing function within Zen Cart that can do that
or can someone give me some pointers on writing my own?

Thanks!