I have a yale delivery box with an electronic latch, and the locking mechanism was snapped by an overaggressive opening. Glue or friction fit a 6x2mm round magnet in the opening. Best to print it with the latch piece parallel to the print bed and the grooves/magnet hole facing up.
I painted on minimal supports in three spots to make it a stronger print. 50% infill, petg.
In the photo, it's just the screwed in bit surrounded in a green box.
The author hasn't provided the model origin yet.