'WordPress plugin extend WC_product with namespace class not found
I am trying to add new woocommerce custom product type from my plugin.
I just have a simple construct in the class that extend WC_Product
namespace giftbox\models\woocommerce;
class register_product_type  extends \WC_Product
{
    public function __construct()
    {
        $this->product_type = 'gift_box';
        parent::__construct( $product );
    }
}
then I am call it by the follow action
add_action( 'init',  array(new register_product_type()) );
this is the error: Uncaught Error: Class 'WC_Product' not found
I am stuck on it because I try different way for solving and no one work for me.
Another example is when I tried to call it by function (has same error)
add_action( 'init',  'register_gift_box_types' );
function register_gift_box_types () {
    class register_product_types extends \WC_Product
    {
        public function __construct( $product ) {
            $this->product_type = 'gift_box';
            parent::__construct( $product );
        }
    }
}
I also tried to include abstract-wc-product.php but return a completely different error "Use of undefined constant WC_ABSPATH."
I know must to be a solution but I am completely stack from a couple of day
I am using namespace and autoloader is possible to find in the follow link (https://gist.github.com/sankarsuda/7818600)
Any idea how to solve this problem? Thanks in advance.
Solution 1:[1]
That is because you not import the class
use WC_Product;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source | 
|---|---|
| Solution 1 | Pablo Mendez | 
