Hauppauge’s Nick Fanti was standing with a friend at a store in the Smith Haven Mall in December, gazing at World Baseball Classic caps and wondering “What if?”

“We were just looking at all the hats and then my buddy asked me, ‘How cool would it be to play in that?’ ’’ said Fanti, a 20-year-old pitcher in the Phillies’ organization. “And I was just like, ‘It would be sick.’ ”

Little did he know that he would be wearing not just a WBC cap but an entire Team Italy uniform — and pitching a scoreless seventh inning against Puerto Rico on Sunday. He faced a few familiar names, retiring former Met Angel Pagan on a fly ball and striking out the Mets’ T.J. Rivera.

Italy faced Venezuela on Monday night in a Pool D tiebreaker game, with the winner advancing to the second round.

Fanti, Newsday’s 2015 high school player of the year and Yastrzemski Award winner as Suffolk’s top player, said he received the invitation to play for Italy just 20 minutes after his December visit to the mall. It came from Brian Sweeney, the pitching coach for the Phillies’ Class A Lakewood affiliate and Team Italy’s pitching coach.

Fanti said he and Sweeney had talked about him pitching in the WBC, or the Olympics in four years, but then Sweeney “called and says, ‘Hey, remember when I said in four years or three years would you want to pitch in a Classic?’ ” Fanti said of their December conversation. “And I’m like, ‘Yeah.’ And he said, ‘Would you want to do it in three months?’

advertisement | advertise on newsday

“It was crazy. I put him on speaker, too, because I couldn’t believe it myself,” Fanti said. “My friend’s jaw dropped because we were literally just talking about it.”

Fanti, who pitched consecutive no-hitters in his senior season at Hauppauge High School in 2015 and received the Yastrzemski Award the same day he was drafted by the Phillies, is coming off a 7-0 season for the Phillies’ rookie-level GCL team. He posted a 1.57 ERA with 65 strikeouts in 51 2⁄3 innings. He’s unsure what level he’ll be pitching at this season when he returns to the Phillies.

After playing in front of smaller crowds in the rookie league, Fanti pitched for Team Italy in an exhibition game Wednesday at the A’s spring training facility against a major-league lineup. The lefthander allowed two runs, two hits, two walks and a hit batsman in the fourth inning but struck out two, including nine-year veteran Adam Rosales.

After giving up a two-run double by Matt Chapman, who went to third on the throw with one out, and hitting former Met Alejandro De Aza to load the bases with two outs, Fanti escaped by getting Mark Canha to ground into a forceout.

Fanti even received compliments on his outing from Oakland players.

@NewsdaySports

“I got done pitching, went to the gym and was working out, and some of those guys that I pitched against were giving me feedback,” Fanti said. “One guy came up to me and was like, ‘Where were you last year?’ and I said ‘Rookie ball’ and he goes, ‘Oh, wow. You’re good, man. Keep doing what you’re doing.’ ”

Team Italy includes major-league talent such as Pirates catcher Francisco Cervelli and Mets outfielder Brandon Nimmo, with Nick Punto and Smithtown’s Frank Catalanotto as base coaches. Fanti has made the most of his opportunities to speak with his established teammates and coaches.

“I’m getting reps and pitching a lot here, and it’s only going to make me better,” he said. “I’m facing all of these big-league hitters, professional hitters, and hopefully it will make wherever I end up this year a little easier.”