title: Empty $woocommerce global variable (WC() works instead)
body: <p>I have this code:</p>
  
  <pre><code>add_action('woocommerce_init', 'on_woocommerce');
  
  function on_woocommerce(){
      function log_cart(){
          global $woocommerce;
          $cart_content = $woocommerce-&gt;cart-&gt;get_cart();
          log_debug($cart_content,'$cart_content');
      }
      if(HLP_DEBUG){
          log_cart();
      }
  }  
  </code></pre>
  
  <p>But it gives me error because $woocommerce is null.  </p>
  
  <p>Instead if I use this:</p>
  
  <pre><code>add_action('woocommerce_init', 'on_woocommerce');
  
  function on_woocommerce(){
      function log_cart(){
         $cart_content = WC()-&gt;cart-&gt;get_cart();
         log_debug($cart_content,'$cart_content');
      }
      if(HLP_DEBUG){
          log_cart();
      }
  }
  </code></pre>
  
  <p>Everything it's right and working.</p>
  
  <p>The code is inside another function executed on <strong><code>woocommerce_init</code></strong> HOOK.  For what is my knowledge both should work. </p>
  
  <p>Could you explain why the first one doesn't?</p>