The phrase about something being in the bag is claimed to come from an old parliamentary tradition, whereby petitions were put into a bag behind the Speaker's chair in the Commons; once in, they would be dealt with, hence 'in the bag' meant it will be done. Half in the bag comes from this - it's nearly there, close to being done.
I love OnlyMe's answer, but I believe 'in the bag/half in the bag' comes from a reference to hunting, the 'bag' in question being the 'game-bag'...ie the one into which the hunter/shooter puts the creatures he has killed. Once they're in there, you're certain of them, as it were.