We compute leading-power fragmentation corrections to hadroproduction of
charmonium states $J/\psi$, $\chi_{cJ}$, and $\psi(2S)$ in the nonrelativistic
QCD factorization formalism.
We include fragmentation functions through order
$\alpha_s^2$ and parton production cross sections through order $\alpha_s^3$.
We also
resum leading logarithms of the transverse momentum divided by the charm-quark
mass to all orders in $\alpha_s$.
We find that the fragmentation corrections have a significant impact on the
hadroproduction cross section of charmonia.
We obtain good fits to the hadroproduction cross sections measured at the
Tevatron and the LHC. Using the long-distance matrix elements obtained from the
fits, we make predictions for prompt $J/\psi$ polarization that are in good
agreement with the LHC data.