title: WordPress plugin extend WC_product with namespace class not found
body: <p>I am trying to add new woocommerce custom product type from my plugin.</p>
  <p>I just have a simple construct in the class that extend WC_Product</p>
  <pre class="lang-php prettyprint-override"><code>namespace giftbox\models\woocommerce;
  
  class register_product_type  extends \WC_Product
  {
      public function __construct()
      {
          $this-&gt;product_type = 'gift_box';
          parent::__construct( $product );
      }
  }
  </code></pre>
  <p>then I am call it by the follow action</p>
  <pre><code>add_action( 'init',  array(new register_product_type()) );
  </code></pre>
  <p>this is the error:
  <strong>Uncaught Error: Class 'WC_Product' not found</strong></p>
  <p>I am stuck on it because I try different way for solving and no one work for me.</p>
  <p>Another example is when I tried to call it by function (has same error)</p>
  <pre class="lang-php prettyprint-override"><code>add_action( 'init',  'register_gift_box_types' );
  function register_gift_box_types () {
      class register_product_types extends \WC_Product
      {
          public function __construct( $product ) {
              $this-&gt;product_type = 'gift_box';
              parent::__construct( $product );
          }
      }
  }
  </code></pre>
  <p>I also tried to include abstract-wc-product.php but return a completely different error &quot;Use of undefined constant WC_ABSPATH.&quot;</p>
  <p>I know must to be a solution but I am completely stack from a couple of day</p>
  <p>I am using namespace and autoloader is possible to find in the follow link (<a href="https://gist.github.com/sankarsuda/7818600" rel="nofollow noreferrer">https://gist.github.com/sankarsuda/7818600</a>)</p>
  <p>Any idea how to solve this problem?
  Thanks in advance.</p>