Print an adhesive (or you can use plastisol ink, although I haven't done it that way) onto the substrate. Dry it. Press a sheet of foil over the top with a heat press. Wait for it to cool. Peel the sheet, and the foil stays on the ink/adhesive parts.
Not a lot to it.