Updates to protect cart template API and WPEC from improper usage

API functions intended to be called from outside of WPeC, perhaps by developers not very familiar with WPeC internals, need to be a little bit "paranoid" and protect against usage that could have unintended consequences. These functions should also do what they can to inform a caller of where a problem was detected and where to go to look to understand and resolve the issue.

This PR :
* Updated documentation
* Added PHPDoc headers
* Confirm globals are initialized before using them.