A serial shoplifter facing a felony charge for allegedly stuffing $31 worth of candy bars into his pockets — making him ripe for a possible 20 years-to-life prison sentence as a habitual offender — was ordered to be jailed Tuesday after he tested positive for opiates, cocaine, oxycodone and marijuana.

Orleans Parish Criminal District Court Judge Franz Zibilich ordered up the test on Jacobia Grimes at the request of District Attorney Leon Cannizzaro’s office, citing a New Orleans Advocate story last week in which Grimes’ attorneys said he had a heroin problem.

Grimes, 34, had been free on $5,000 bail following a Feb. 3 bill of information charging him under a state statute for theft of goods by someone with multiple prior convictions for the same thing. The earlier shoplifting convictions elevated his alleged candy heist, at a Dollar General store on South Claiborne Avenue, to a felony.

Zibilich said Grimes had tested positive for “huge” amounts of cocaine and opiates.

“This is a clear violation of bond. If I wanted to be a cynic, I would say he’s stealing candy bars for money to buy cocaine and marijuana,” the judge said before a bailiff placed Grimes, shoulders slumped, in handcuffs.

His attorneys, Miles Swanson and Michael Kennedy, said they would provide the judge by Monday with a prescription they said Grimes had obtained for the unidentified opiates.

“Our client is documented to have a drug problem,” Kennedy said later. “This does not come as a surprise.”

Grimes’ attorneys argue that the potential life sentence for a drug-addicted candy thief illustrates a need for reform in sentencing laws in Louisiana, a state with the highest incarceration rate of any state in the U.S. — or any country in the world.

Whether Grimes would face 20 years to life if he’s convicted of the candy theft would be up to Cannizzaro’s office, under state laws that give prosecutors the discretion following a conviction to raise the ante by filing a “multiple bill.”

The specter of such lengthy prison terms, defense attorneys say, leaves defendants over a barrel.

“I just think it points to the absurdity of the multiple-billing statute. They’re spending their time to lock someone up for years over $31 worth of candy. It’s ridiculous,” Swanson said last week.

Cannizzaro’s office chose to charge Grimes under a statute that sets a maximum two-year prison sentence for a repeat shoplifter. Grimes has no violent criminal history, his attorneys say, but his five prior shoplifting convictions leave him vulnerable to being sentenced as a “quad” offender, a status that leaves little discretion to a judge.

Cannizzaro takes a dim view of the notion that he would abuse his discretion regarding the state’s habitual offender law, writing in a letter to The Advocate on Tuesday that “shoplifters will not be doing 20-year sentences.”

But Cannizzaro also argued that his office has repeatedly sought funding to place men such as Grimes in a diversion program to receive mental health and substance abuse counseling.

“The city, however, has routinely denied those requests,” Cannizzaro wrote. “As such, the DA’s Office must choose between the lesser of two evils — putting this defendant back on the street without any rehabilitation or putting him in jail.”

His office chose the latter option in 2010, when Grimes was convicted for the same offense, for shoplifting socks and trousers, Swanson said.

In that case, Cannizzaro’s office filed a multiple bill for Grimes as a two-time offender, though Grimes was eligible then as well to face 20 years to life, according to the District Attorney’s Office.

Grimes received a four-year prison term in that case, serving more than three years before his release in August 2013. That was the most recent of five prison stints, totaling almost nine years, that Grimes has served since 2001, mostly for shoplifting convictions.

From the bench Tuesday, Zibilich suggested a compromise plea agreement that would take the specter of a massive prison sentence off the table for Grimes.

“If this will make the District Attorney’s Office feel better, if some sort of sentence coupled with drug court might be OK for both sides, this court would be all for that,” Zibilich said. “Because he has a problem. I’m just tossing it out there. The man needs help.”