(CNN) An undercover operation in California found that half of tobacco and vape shops failed to check IDs for teens purchasing e-cigarettes and other nicotine products, despite a state law raising the legal age for purchasing tobacco products to 21.

Researchers sent 18- and 19-year-old "decoys" into stores without ID, instructing them to tell the truth about their age if asked. The teenagers then attempted to purchase vape products -- e-cigarettes or e-liquids with nicotine -- and a chaperone watched to see if the store asked for ID and made a sale.

Almost half of tobacco and vape shops illegally sold nicotine-containing products to the teens, according to the research, published Monday in the medical journal JAMA Pediatrics. Liquor stores, supermarkets and pharmacies were significantly more likely to check for ID and less likely to make the illegal sales.

The research team, consisting of scientists from the California Department of Public Health and Stanford University, also found that vape and tobacco shops were more likely to sell teenagers vape products than traditional cigarettes.

It's unclear why that's the case, but "one possibility may be that vape products cost more and they might have a higher profit margin for retailers, so the temptation is greater to sell," said Lisa Henriksen, a co-author of the study and a senior research scientist at the Stanford Prevention Research Center.