Make scripts that use global objects safe on non WC pages.

This commit allows the scripts to bail out immediately if the dependent
global woocommerce objects are not present on the page.