The first sentence establishes that the purchase happened in the past. Therefore, the conditional sentence must describe a hypothetical past situation, which requires the third conditional: past perfect ("had had") in the "if" clause and "would have" + past participle ("would have bought") in the main clause.