Buying a pig in a poke means purchasing something without thoroughly examining it. The origin of this phrase came from the practice of selling dead dogs wrapped in a poke (old word for bag) instead of the expected pig. The unlucky victim of the scheme would arrive home to find that the merchant did not indeed bag the pig but a mangy dog instead. Letting the cat out of the bag refers to someone arriving home with what they think is a hare in a bag but is instead a cat. The Spanish equivalent of that phrase is dar gato por liebre meaning to give a cat instead of a hare.
Side note: poke is derived from the French word poque. This is also the origin of our word pocket meaning a little bag.
The idea of buying a pig in a poke has made its way into most major languages in some derivation. يشتري سمك في ماء is Arabic for buying a fish in water (and not ending up with the one you wanted). 挂羊头卖狗肉 is Chinese for selling dog meat as mutton. Acheter chat en poche is French for buying a cat in a sack. The list of related idioms goes on and on.
To move on to a related but slightly different topic, in English and French canard means a hoax, but is also the French word for duck. How did the word duck come to mean a hoax? The French phrase vendre des canards à moitié means to half-sell ducks or to cheat. Clearly, back in these times people often went to the market and were swindled and our language reflects that.