Thomas J. Franzen, 37, pleaded guilty to possession of more than 5,000 grams of cannabis, a felony that carries a prison term of four to 15 years and a fine of up to $25,000, according to court records.

MONTGOMERY, Ill. (WREG/CNN) -- A man from suburban Chicago was sentenced to four years in prison after he ordered 42 pounds of marijuana-infused chocolate from California with the intention of selling it, the Kane County state’s attorney’s office said in a statement.

Thomas J. Franzen, 37, pleaded guilty to possession of more than 5,000 grams of cannabis, a felony that carries a prison term of four to 15 years and a fine of up to $25,000, according to court records.

In February 2014, postal workers noticed a pattern of suspicious packages being delivered to Franzen’s home in Montgomery, Illinois, the state’s attorney’s office said. After obtaining a search warrant to open a package, they found more than 19,000 grams of chocolate infused with THC.

Authorities then got a warrant to search Franzen’s home and found cocaine and more than 100 additional grams of marijuana, along with items that are “known to be evidence of drug dealing,” the state’s attorney’s office said. Those items included a digital scale, more than $2,000 in cash and postal receipts for packages he had mailed to locations across the US and Canada.

Franzen’s attorney, David Camic, said his client has had testicular cancer and was undergoing treatment for it at the time that he ordered the marijuana.

“In recognition of the seriousness of Mr. Franzen’s medical condition, our office reduced a 12-year mandatory minimum sentence to 4 years, of which he is required to serve only 2 years,” Kane County State’s Attorney Joe McMahon said in the statement. “We did this in spite of evidence that proves that Mr. Franzen is a drug dealer.”

Court records show prosecutors dismissed several more serious charges of marijuana trafficking, a felony that is punishable by six to 30 years in prison and a fine of up to $25,000.

Franzen’s sentence came just one day before the Illinois legislature voted to legalize recreational marijuana. Gov. J. B. Pritzker has pledged to sign the law, which would take effect January 1, 2020.

Franzen is due in court for a hearing on June 14, when he will present medical test results to a judge who will decide when he begins his prison sentence.