In our recent declutter, I got the kids to go through their clothes and bag up the things they had grown out of. My daughter included these shorts because of the broken zip. They still fit and were in good nick apart from the zip, so they were worth the 20 minutes and $1 to fix them. Here's how:
With a seam ripper, remove the stitches that held the zipper in place. You'll create a "hole" in the fly underlap. On the overlap side, simply pick out the stitches. The fly went up into the waistband area on these shorts, so I didn't have to cut the zipper out of the waistband. If you have a more traditional waistband, you might need to do this.
These shorts have only a very short fly, so I needed to shorten the zip. I measured the new zip against the old, then stitched in a new zipper stop to match the old zip. Then I cut off the excess zip.
With the zipper right side up and closed, I slid it into the slot on the fly underlap side of the fly. Pin it down, and using a zipper foot on the machine, stich close to the zip.