I bought a new phone the other day and it came on a neat sliding cardboard box, Inspired by it i made this earphone case:
The case comes in three parts, and it was made to lock using magnets, so you’ll also need two 6 mm diameter by 3 mm magnets, or any magnet that fits:
Glue the magnets in in place, be sure to position them with opposite poles, and then glue the cap on the drawer thingy, i used epoxy but any glue should do the job, solvent weld might be best if you’re printing in ABS though.
Make sure you’re gluing the cap in the right orientation also. And let the glue dry with the box closed to ensure alignment