I am going to (reluctantly and rarely!) disagree with all of the above.
For ANY FLANGE, you MUST order by ALL of the following:
Nominal diameter
Material (and sometimes with certification papers)
Type of flange and Flange face: RFWN, RFSO, RFSW, FFWN, API style, etc
Class or "Pressure Rating": This value is ESSENTIAL for mating with the opposite flange.
It defines these:
the number of bolt holes,
dia of bolt holes,
bolt circle diameter,
thickness of flange and diameter of flange,
dia of raised face,
and (if present), the OD and height of "the back side" for the pipe socket weld or slip on reinforcement.
You "never" need the Pipe ID to select a flange Class - which is the only thing defined by the pipe schedule.
RFWN ? - Check me.
Now, having said that last, "pipe schedule" should usually match what the pressure rating or class of the flange will be. A 10 Sch 10 Stainless steel pipe will not need a Class 600 flange - Usually. A Class 150 flange should be reviewed very, very carefully if it is being connected to a Sch160 heavy wall pipe.
Remember the history of piping. Class ratings for flanges only came about when the higher pressure superheated steam became possible with the higher quality steel after the US Civil War and the Bessemer and Siemens steel production became reliable. Then, flange ratings were named for matching the strength of common steel at the temperature and pressure of the saturated steam inside the pipe.