Why did xander wear an eyepatch in Buffy?

The first time he wore an eye patch was part of a costume. He was a pirate.

In season seven, however, he lost his eye in a fight with Caleb (played by Nathan Fillion) and had to wear an eye patch from then on.