Removed unused global variables in local scopes

Stripped lots of old `$woocommerce` references and other global variables accessed in global scope.