You could store the "owner" of each item (the player who buys it) in a hashtable. When a unit acquires an item, if they are not owned by the same player as the owner of the item, it drops automatically.
It might also be easier depending on how this is set up. You could make a trigger that drops any item they get immediately. When you have the hero buy items, assuming it is triggered AI, you can turn off the trigger while they do their item purchases and turn it back on right after (I mean within the same function call). That way, only the items they buy will make it through the auto-drop trigger.