title: Checking if WooCommerce is active and what version is used
body: <p>I need to check if WooCommerce is active and check its version number to make it work differently for new and old versions.</p>
  
  <p>I found that <code>WC_VERSION</code> stores version number, so if it exists, it also means that WooCommerce is active. The problem is that it can return anything only after plugins are loaded. I would like to check version and then use outside <code>woocommerce_ver_check function</code> in general scope. Can I do it without global variables?</p>
  
  <p>I want to do something like this, but <code>woocommerce_ver_check()</code> is always null, because it executes after WooCommerce is loaded, unlike the rest of the code which is not assigned to any hook:</p>
  
  <pre><code>// Check WooCommerce version.
  add_action('plugins_loaded', 'woocommerce_ver_check');
  function woocommerce_ver_check() {
      if (defined('WC_VERSION')) return WC_VERSION; 
  }
  
  // Only if WooCommerce is active.
  if (! woocommerce_ver_check() == null  ) {
      if ( version_compare( WC_VERSION, '3.0', '&gt;=' ) ) {
          // new version code
      } else {
          // old version code
      }
  }
  </code></pre>