"would like" isn't a conditional construction by itself, it's a more polite version of "want".
if you need 2nd conditional in your dialogue, then don't use would + perfect infinitive, it makes the conditional mixed, it should be "- If you gave me a 10% discount, I would buy this hat!"
And your last example is 3rd conditional, you should use "like" there too:
""If he had given me a 10% discount, I would have bough this hat. But he didn't change the price."