If you agree a price to buy it, you then apply for permission. The sale only goes ahead if buyer is able to obtain planning. But buyer bears all the costs of planning application.
Check if there have been any previous applications before you proceed.
And make sure you consult a solicitor. I'm aware of cases where the agreed price changed once planning was granted because they hadn't done contracts first.