Saints finished fourth and Warrington's victory at Hull means they will face the League Leaders' Shield winners away from home in their play-off semi-final.
Tries from Louie McCarthy-Scarsbrook and Jack Owens put Saints 12-6 up at the break, with Craig Hall responding.
McDonnell's treble after the break helped to seal the win.
Theo Fages added the hosts' sixth try to complete the victory, while Wakefield - who suffered a ninth successive defeat and finished bottom of the table at the end of the Super 8s - managed only a Tom Johnstone score in reply after the break.
Victory extends St Helens' winning run to four matches leading up to the play-offs, with their only defeat in their past 12 games coming at Warrington in August.
They now travel to face the Wolves at the Halliwell Jones Stadium on Thursday, 29 September, looking to return to the Super League Grand Final for the eighth time in 11 seasons.
St Helens assistant coach Sean Long: "Shannon had a great game and went really well against Widnes last week. He's given us a headache for next week.
"Full credit to Wakefield who had a real dig at us. We were a little bit off and it wasn't a great spectacle, but we would have taken 32-12 before the game.
"The main thing is we came through unscathed for next week."
Wakefield head coach Chris Chester: "We played some really good football at times. We wanted to throw the ball around and enjoy ourselves and there was a lot of spirit and pride.
"We probably tried too hard in the second half but the final scoreline didn't reflect our effort.
"We have got into the top eight through hard work and we now have to continue with our progression."
St Helens: Lomax; McDonnell, Percival, Peyroux, Owens; Turner, Walsh; Vea, Knowles, Amor, McCarthy-Scarsbrook, Greenwood, Thompson.
Replacements: Walmsley, Wilkin, Fages, Davies.
Wakefield: Jowitt; Johnstone, Lyne, Arundel, B Tupou; Hall, Finn; Simon, Sio, Fifita, Molloy, Ashurst, Harrison.
Replacements: A Tupou, Arona, Crowther, Yates.
Referee: Joe Cobb

The Gunners lost 3-2 at Old Trafford and 2-1 at home to Swansea to slip six points behind leaders Leicester.
"Sometimes we lack the mentality that we are already winning 1-0 when we go out on to the pitch," Sanchez told Directv Sports before the United match.
"We lack this hunger to believe that we can be champions."
Sanchez added: "If we go out onto to the pitch with hunger to become champions, to win the Premier League or the Champions League we can achieve it.
"I remember a game against Manchester United last year. The lads looked hungry for silverware as we took to the pitch.
"We crushed them in the first 20 minutes and went 3-0 up. We were hungry and brimming with confidence that day."
Arsenal have only three wins from 11 games in all competitions and are third in the league.
Speaking after Wednesday's loss to Swansea, Gunners manager Arsene Wenger also said his side's loss of form "looks a bit" like a confidence issue.
"I am worrying about our results," he said. "We don't dream. We have to be realistic and come back to what we do well... the basics.
"The players are very down but we have to respond. We have to focus on our job and remind ourselves that we have some quality as well."
Shannon McDonnell's hat-trick helped St Helens round off the regular Super League season with a routine home win over Wakefield at Langtree Park.
[NEXT_CONCEPT]
Alexis Sanchez said Arsenal lacked the self-belief to win the Premier League even before their back-to-back defeats by Manchester United and Swansea.