Fix IE8 compatibility issues with checkout.js and products.js

IE8 has a weird bug where function definitions outside of a ready statement were not being acknowledged. Moving them to being inside the ready statement fixes this issue.

See #3499 for a screenshot.