He was the mystery man who gained viral notoriety for buying $540 worth of Girl Scout cookies so the girls wouldn't have to stand out in the cold. And now, garnering attention of an entirely different sort, he was arrested on drug charges on Tuesday at his home in Greenville, South Carolina.

The man, identified as Detric Lee McGowan, 46, appeared in federal court; he faces drug and conspiracy charges relating to manufacturing heroin and fentanyl pills.

Drug Enforcement Administration (DEA) agents were investigating McGowan for six months and planned on arresting him Tuesday, long before the photo of him smiling next to two Girl Scouts went viral.

“It was all a coincidence,” a DEA source told Fox News.

McGowan “used his story of buying $540 of Girl Scout cookies to falsely shine the spotlight on himself under the pretense of being a pillar of the community; in reality, he is a pariah to the community,” said Robert J. Murphy, the special agent in charge of the DEA's Atlanta field division. “His criminal conduct provided no positive benefit to the Greenville community, but only caused immeasurable and untold pain to the scores of families who are dealing with opioid addiction.

"Now that this defendant is behind bars, the Greenville community can celebrate the true heroes (the dedicated men/women in law enforcement) who work tirelessly to ensure their community is a safe place to raise families.”

The viral Facebook post, shared over 9,000 times, said McGowan initially purchased seven boxes of cookies from the girls, who'd set up a stand outside a store in Greenville.

FRIENDS SEEK TO CLEAR HOUSTON COUPLE KILLED IN DRUG RAID

He gave them $40 and told them to keep the change. Then later, he came back and spent $500 more to purchase every cookie box the girls were selling.

“Pack up all of your cookies. I’m taking them all so y’all can get out of this cold,” McGowan told the girls, according to the Facebook post.

McGowan never gave his name to the Girl Scouts, but the DEA knew him.

CLICK HERE TO GET THE FOX NEWS APP

The drug suspect has a history of prior drug dealing charges. He’s been arrested six times before and has served time in federal prison.

Most recently McGowan served two and a half years for cocaine possession with intent to distribute.

Fox News' Bryan Llenas contributed to this report.