Can you buy opiates online?

Sure, but not legally. Here are some factors to consider:
What kind of opiates do you want? If you are looking to buy oxycodone(percocet) or hydrocodone(vicodin) be prepared to enter the world of fake pills and ripoffs that will simply take your money. You are better off buying from your local drug dealer, If you do the research on some of the shadowey chat sites that discuss such things and find a site that is actually selling such, be prepared to spend alot of money!! Most of these sites come and go and will happily take you money long after they have stop actually delivering
Codeine is another matter. Alot of countries sell it over the counter and you can find online sites that sell it. It is still illegal and be ready to lose out if customs finds it, but there is little risk unless you try to order a ton of the stuff. Brand names like arcedol are commonly found, It is the equivalent to tylonol 3,
Of course the best thing is to just forget it. But it took me thousands of dollars in ripoffs to come to that conclusion!!