A replacement as spike outlines is an easy and (relatively) cheap solution.
But isn't the default issue for the boot to lock and not open?
For example if closed with the battery disconnected the boot should lock?
You could try to see if the mechanism works by clearing out the boot, folding down the rear seats (so you can access the battery) and then disconnect the battery and then close the boot. If it does not latch then it would show the problem is in the mechanism whilst if it locks I guess the problem could be in the electronics...
It may be worth trying that before buying a new lock just in case it was a problem with the electronics?
John